Skip to content

Instantly share code, notes, and snippets.

@xkef
Forked from yashkumaratri/Google Colab SSH
Last active March 15, 2020 20:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xkef/b953bc5a199f53a8ece034a51df05fcf to your computer and use it in GitHub Desktop.
Save xkef/b953bc5a199f53a8ece034a51df05fcf to your computer and use it in GitHub Desktop.
SSH into google colab
#CODE
#Generate root password
import random, string
password = ''.join(random.choice(string.ascii_letters + string.digits) for i in range(20))
#Download ngrok
! wget -q -c -nc https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip
! unzip -qq -n ngrok-stable-linux-amd64.zip
#Setup sshd
! apt-get install -qq -o=Dpkg::Use-Pty=0 openssh-server pwgen > /dev/null
#Set root password
! echo root:$password | chpasswd
! mkdir -p /var/run/sshd
! echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
! echo "PasswordAuthentication yes" >> /etc/ssh/sshd_config
! echo "LD_LIBRARY_PATH=/usr/lib64-nvidia" >> /root/.bashrc
! echo "export LD_LIBRARY_PATH" >> /root/.bashrc
#Run sshd
get_ipython().system_raw('/usr/sbin/sshd -D &')
#Ask token
print("Copy authtoken from https://dashboard.ngrok.com/auth")
import getpass
authtoken = getpass.getpass()
#Create tunnel
get_ipython().system_raw('./ngrok authtoken $authtoken && ./ngrok tcp 22 &')
#Print root password
print("Root password: {}".format(password))
@xkef
Copy link
Author

xkef commented Jan 19, 2020

then just

! curl -s http://localhost:4040/api/tunnels

to get network routes, ssh root@<route> -p <port>

@xkef
Copy link
Author

xkef commented Jan 19, 2020

install hashcat, don't forget to mount drive with

from google.colab import drive
drive.mount('/content/drive')
# install hashcat
apt install cmake build-essential -y && apt install checkinstall git -y
git clone https://github.com/hashcat/hashcat.git 
cd hashcat 
git submodule update --init
make && make install

@xkef
Copy link
Author

xkef commented Jan 19, 2020

make session persistent:

open dev console and add:

function ClickConnect() {
    console.log("Working"); 
    document.querySelector('colab-toolbar-button#toolbar-add-code').querySelector('paper-button').click()
}

setInterval(ClickConnect,60000)

@xkef
Copy link
Author

xkef commented Jan 19, 2020

https://sarwiki.informatik.hu-berlin.de/WPA2-Angriff

pip install gpustat
watch -n 0.5 -c gpustat -cp --color 

ctrl b : -> :resize-pane -U 30

hashcat -D 2 -w 3 -m 2500 -a 0 '1337.hccapx' 'rockyou.txt' -r '/rules/oscommerce.rule' --potfile-path cracked.pot

@xkef
Copy link
Author

xkef commented Jan 31, 2020

wget http://downloads.skullsecurity.org/passwords/rockyou.txt.bz2
bzip2 -d rockyou.txt.bz2

@xkef
Copy link
Author

xkef commented Mar 15, 2020

bd4fa7e811a828c7f14af9f5581bcf94:bl0ckch41n42

# create leetspeak rockyou list
cat /content/drive/My\ Drive/rockyou1.txt | hashcat -w4 -r /content/hashcat/rules/unix-ninja-leetspeak.rule --stdout > /content/drive/My\ Drive/combi3_.txt

# create list of numbers
seq 0 100000 > /content/drive/My\ Drive/nrs.txt

# run hashcat in a1 (combi -> lhs leetcode, rhs nrs)
hashcat -m 0 -a 1 -w 4 -o /content/drive/My\ Drive/cracked_out.txt to_crack_hash.txt /content/drive/My\ Drive/combi.txt /content/drive/My\ Drive/nrs.txt -O

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment