This repository has been archived by the owner on Nov 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 120
/
build.sh
122 lines (108 loc) · 4.9 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/bin/bash
# Modified from https://github.com/palera1n/palen1x
[ "$(id -u)" -ne 0 ] && {
echo 'Please run as root'
exit 1
}
ROOTFS='https://dl-cdn.alpinelinux.org/alpine/v3.17/releases/x86_64/alpine-minirootfs-3.17.3-x86_64.tar.gz'
cat << EOF
█ ██ ███▄ █ ██████ ██░ ██ ▄▄▄ ▄████▄ ██ ▄█▀ ██▓ ▓█████
██ ▓██▒ ██ ▀█ █ ▒██ ▒ ▓██░ ██▒▒████▄ ▒██▀ ▀█ ██▄█▒ ▓██▒ ▓█ ▀
▓██ ▒██░▓██ ▀█ ██▒░ ▓██▄ ▒██▀▀██░▒██ ▀█▄ ▒▓█ ▄ ▓███▄░ ▒██░ ▒███
▓▓█ ░██░▓██▒ ▐▌██▒ ▒ ██▒░▓█ ░██ ░██▄▄▄▄██ ▒▓▓▄ ▄██▒▓██ █▄ ▒██░ ▒▓█ ▄
▒▒█████▓ ▒██░ ▓██░▒██████▒▒░▓█▒░██▓ ▓█ ▓██▒▒ ▓███▀ ░▒██▒ █▄░██████▒░▒████▒
░▒▓▒ ▒ ▒ ░ ▒░ ▒ ▒ ▒ ▒▓▒ ▒ ░ ▒ ░░▒░▒ ▒▒ ▓▒█░░ ░▒ ▒ ░▒ ▒▒ ▓▒░ ▒░▓ ░░░ ▒░ ░
░░▒░ ░ ░ ░ ░░ ░ ▒░░ ░▒ ░ ░ ▒ ░▒░ ░ ▒ ▒▒ ░ ░ ▒ ░ ░▒ ▒░░ ░ ▒ ░ ░ ░ ░
░░░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░░ ░ ░ ▒ ░ ░ ░░ ░ ░ ░ ░
░ ░ ░ ░ ░ ░ ░ ░░ ░ ░ ░ ░ ░ ░ ░
░
open source tool to bypass windows and linux passwords
github : https://github.com/Fadi002/unshackle
EOF
apt-get update
apt-get install -y --no-install-recommends wget gawk debootstrap mtools xorriso ca-certificates curl libusb-1.0-0-dev gcc make gzip xz-utils unzip libc6-dev
VERSION=$(<version)
# Clean up previous attempts
umount -v work/rootfs/{dev,sys,proc} >/dev/null 2>&1
rm -rf work
mkdir -pv work/{rootfs,iso/boot/grub}
cd work
# Fetch ROOTFS
curl -sL "$ROOTFS" | tar -xzC rootfs
mount -vo bind /dev rootfs/dev
mount -vt sysfs sysfs rootfs/sys
mount -vt proc proc rootfs/proc
cp /etc/resolv.conf rootfs/etc
cat << ! > rootfs/etc/apk/repositories
http://dl-cdn.alpinelinux.org/alpine/v3.12/main
http://dl-cdn.alpinelinux.org/alpine/edge/community
http://dl-cdn.alpinelinux.org/alpine/edge/testing
!
sleep 2
# ROOTFS packages & services
cat << ! | chroot rootfs /usr/bin/env PATH=/usr/bin:/usr/local/bin:/bin:/usr/sbin:/sbin /bin/sh
apk update
apk upgrade
apk add bash alpine-base ncurses udev newt lsblk linux-headers usbutils xkeyboard-config
apk add linux-headers
apk add xkeyboard-config
apk add ntfs-3g
apk add e2fsprogs
apk add coreutils
apk add usbutils
apk add --no-scripts linux-lts linux-firmware-none
modprobe hid-generic
rc-update add bootmisc
rc-update add hwdrivers
rc-update add udev
rc-update add udev-trigger
rc-update add udev-settle
!
# kernel modules
cat << ! > rootfs/etc/mkinitfs/features.d/unshackle.modules
kernel/net/ipv4
modprobe hid-generic
!
chroot rootfs /usr/bin/env PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin \
/sbin/mkinitfs -F "unshackle" -k -t /tmp -q $(ls rootfs/lib/modules)
# rm -rfv rootfs/lib/modules
mv -v rootfs/tmp/lib/modules rootfs/lib
find rootfs/lib/modules/* -type f -name "*.ko" -exec strip -v --strip-unneeded {} \; -exec xz --x86 -v9eT0 \;
depmod -b rootfs $(ls rootfs/lib/modules)
# Echo TUI configurations
echo 'unshackle' > rootfs/etc/hostname
echo "PATH=$PATH:$HOME/.local/bin" > rootfs/root/.bashrc # d
echo "export unshackle_VERSION='$VERSION'" > rootfs/root/.bashrc
echo "chmod -v 755 /usr/bin/*" > rootfs/root/.bashrc
echo '/usr/bin/unshackle_menu' >> rootfs/root/.bashrc
echo "" > rootfs/usr/bin/.args
# Unmount fs
umount -v rootfs/{dev,sys,proc}
# Copy files
cp "../unshackle" rootfs/usr/bin/unshackle
cp "../removal_util.exe" rootfs/usr/sbin/removal_util.exe
cp "../payload.sh" rootfs/usr/sbin/payload.sh
chmod +x rootfs/usr/bin/unshackle
cp -av ../inittab rootfs/etc
cp -v ../scripts/* rootfs/usr/bin
chmod -v 755 rootfs/usr/local/bin/*
chroot rootfs /usr/bin/env PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin \
chmod -v 755 /usr/local/bin/*
ln -sv sbin/init rootfs/init
ln -sv ../../etc/terminfo rootfs/usr/share/terminfo # fix ncurses
# Boot config
cp -av rootfs/boot/vmlinuz-lts iso/boot/vmlinuz
cat << ! > iso/boot/grub/grub.cfg
insmod all_video
echo 'unshackle $VERSION'
linux /boot/vmlinuz quiet loglevel=3
initrd /boot/initramfs.xz
boot
!
# initramfs
pushd rootfs
rm -rfv tmp/* boot/* var/cache/* etc/resolv.conf
find . | cpio -oH newc | xz -C crc32 --x86 -vz9eT$(nproc --all) > ../iso/boot/initramfs.xz
popd
# ISO creation
grub-mkrescue -o "unshackle-$VERSION.iso" iso --compress=xz