Skip to content

Instantly share code, notes, and snippets.

@Bryan1998
Last active February 28, 2020 00:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save Bryan1998/c2ea34926c829bbbd33d60715fe01a50 to your computer and use it in GitHub Desktop.
Save Bryan1998/c2ea34926c829bbbd33d60715fe01a50 to your computer and use it in GitHub Desktop.
FBCTF Bases
### DEBIAN STRETCH ###
PART I: python script
Become root.
1. $ sudo -i
Make fbctf directory in /opt
2. # cd /opt
3. # mkdir fbctf
Get my modified score_base.py script
4. # wget https://gist.githubusercontent.com/Bryan1998/772cf58e6aff7cf360387886f5af56ff/raw/0eae6687df97af7c8246ff468f142730c8375c3c/score_base.py
Add python script to cron
5. # crontab -e
a. add this to the bottom: @reboot python /opt/fbctf/score_base.py
b. save and exit
c. reboot machine: # reboot NOW
PART II: chroot environment
Create user "johnny"
MAKE SURE YOU ARE ROOT!
1. # adduser johnny
a. enter password and press enter for all the fields
Kick off user "Johnny" after 2 minutes
2. crontab -e
a. add this to the bottom: */2 * * * * killall -u johnny -HUP
b. save and exit
Now for the actual chroot.
Add links to devices
3.
a. # mkdir -p /home/johnny/dev/
b. # cd /home/johnny/dev/
c. # mknod -m 666 null c 1 3
d. # mknod -m 666 tty c 5 0
e. # mknod -m 666 zero c 1 5
f. # mknod -m 666 random c 1 8
4.
a. # chown root:root /home/johnny
b. # chmod 0755 /home/johnny
c. # ls -ld /home/johnny
5.
a. # mkdir -p /home/johnny/bin
b. # cp -v /bin/bash /home/johnny/bin/
c. # cp -v /bin/cat /home/johnny/bin/
d. # cp -v /bin/ls /home/johnny/bin/
6.
a. # mkdir -p /home/johnny/lib/x86_64-linux-gnu
b. # cp /lib/x86_64-linux-gnu/(libc.so.6,libdl.so.2,libncursesw.so.5,libpcre.so.3,libpthread.so.0,libselinux.so.1,libtinfo.so.5,libz.so.1) /home/johnny/lib/x86_64-linux-gnu/
7.
a. # mkdir -p /home/johnny/lib64
b. # cp /lib64/ld-linux-x86-64.so.2 /home/johnny/lib64
8.
a. # touch /home/johnny/.score_points
b.
9.
a. # cd /home/johnny/
b. # wget https://gist.githubusercontent.com/Bryan1998/117c0d6688bc4bd90a246927035677b6/raw/857ce5aba7187ecd774ffaf62e51181b45de4fb8/hint.sh
c. # chmod a+x hint.sh
PART III: Configuring SSH for chroot
1.
a. # nano /etc/ssh/sshd_config
b. add this to the bottom:
--START--
Match User tecmint
ChrootDirectory /home/test
--END--
c. save and exit
2.
a. # systemctl restart sshd
PART IV: THE END!!
AWESOME! You just did a FBCTF base.
When adding a base, save it, then edit it and add a link, such as: 10.183.3.3:12345
Now for it to ACTUALLY work you need to turn off the game and turn it back on.
MAKE SURE THE BASE IS RUNNING BEFORE YOU TURN THE GAME BACK ON!!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment