39 lines
1.6 KiB
Bash
Executable File
39 lines
1.6 KiB
Bash
Executable File
#!/bin/sh
|
|
# ARG 1: LIB PATH
|
|
# ARG 2: LIB DIR
|
|
|
|
main() {
|
|
# copy libs
|
|
find $1/bin $1/$2 -type d | sed -r 's/'$1'\/(bin|'$2')\///;Tn;s/^/mkdir lindows_c\/Windows\/System32\//;by;:n;d;:y;e' > /dev/null;
|
|
find $1/bin -type f | sed -r 's/'$1'\/bin\/(.*)/cp '$1'\/bin\/\1 lindows_c\/Windows\/System32\/\1.exe/;e' > /dev/null
|
|
find $1/$2 -type f | sed -r 's/'$1'\/'$2'\/(.*)/cp '$1'\/'$2'\/\1 lindows_c\/Windows\/System32\/\1/;e' > /dev/null
|
|
|
|
# ntfs-3g cant seem to figure out ntfs symlinks, its 1500 lines of code for reparse points dont even work
|
|
# with symlinks, so we have to build the reparse point and do it ourselves
|
|
for lib in $(cd $1/$2 && find -type l); do
|
|
WPATH="$(echo -n $(readlink "$1/$2/$lib"))"
|
|
LPATH="$(echo -n '/Windows/System32/'"$WPATH" | sed -E 's/(.)/\1\\x00/g;s/\//\\\\/g')" # sed -E 's/(.)/\\0\1/g');
|
|
LPATHL=$(( 36 + ${#WPATH} * 2 ));
|
|
|
|
LPATHL1=$(printf "%o" $((($LPATHL >> 8 ) & 255 )) );
|
|
LPATHL0=$(printf "%o" $((($LPATHL ) & 255 )) );
|
|
|
|
LBUF="\\x00\\x00\\$LPATHL0\\$LPATHL1\\x00\\x00\\$LPATHL0\\$LPATHL1\\x00\\x00\\x00\\x00$LPATH"
|
|
LBUFL=$(( 12 + $LPATHL ))
|
|
LBUFL1=$(printf "%o" $((($LBUFL >> 8) & 255 )) );
|
|
LBUFL0=$(printf "%o" $((($LBUFL ) & 255 )) );
|
|
|
|
touch "lindows_c/Windows/System32/$lib";
|
|
setfattr -h -n system.ntfs_reparse_data \
|
|
-v "0S$(printf "\x0C\\x00\\x00\xA0\\$LBUFL0\\$LBUFL1\\x00\\x00$LBUF" | base64 -w0)"\
|
|
"lindows_c/Windows/System32/$lib";
|
|
|
|
#ln -sr "lindows_c/Windows/System32/$(readlink $1/lib/$lib)" "lindows_c/Windows/System32/$lib"
|
|
done
|
|
}
|
|
|
|
[ -z "$2" ] && main "$1" lib;
|
|
[ -n "$2" ] && main "$1" "$2";
|
|
|
|
exit 0;
|