Added links/Cleaned out a couple cull sectionspull/4/head
@ -0,0 +1,307 @@ | |||
USAGE | |||
Androaxml | |||
Androapkinfo | |||
Androcsign | |||
Androdd | |||
Androdiff | |||
Androdump | |||
Androgexf | |||
Androlyze | |||
Andromercury | |||
Androrisk | |||
Androsign | |||
Androsim | |||
Androxgmml | |||
Apkviewer | |||
USAGE | |||
Androaxml | |||
BlogPost1 | |||
You can used it to transform Android's binary XML (eg: AndroidManifest.xml) into classic xml (human readable ;)). | |||
$ ./androaxml.py -h | |||
Usage: androaxml.py [options] | |||
Options: | |||
-h, --help show this help message and exit | |||
-i INPUT, --input=INPUT | |||
filename input (APK or android's binary xml) | |||
-o OUTPUT, --output=OUTPUT | |||
filename output of the xml | |||
-v, --version version of the API | |||
$ ./androaxml.py -i yourfile.apk -o output.xml | |||
$ ./androaxml.py -i AndroidManifest.xml -o output.xml | |||
Androapkinfo | |||
This tool displays information on a given APK: | |||
permissions | |||
services | |||
activities | |||
receivers | |||
usage of native code | |||
usage of native code | |||
axelle$ ./androapkinfo.py -i qicsomos.apk | |||
FILES: | |||
META-INF/MANIFEST.MF META-INF/MANIFEST.MF -7eb55c04 | |||
res/layout/main.xml res/layout/main.xml 54a83b5b | |||
AndroidManifest.xml AndroidManifest.xml 2eef2f86 | |||
res/drawable-mdpi/ic_launcher.png res/drawable-mdpi/ic_launcher.png -22437ab | |||
res/drawable-hdpi/ic_launcher.png res/drawable-hdpi/ic_launcher.png -4e108fda | |||
META-INF/PLATFORM.RSA META-INF/PLATFORM.RSA 5c8d71d3 | |||
META-INF/PLATFORM.SF META-INF/PLATFORM.SF 5b48f7ec | |||
resources.arsc resources.arsc -55923b8c | |||
classes.dex classes.dex -bafd464 | |||
res/drawable-ldpi/ic_launcher.png res/drawable-ldpi/ic_launcher.png -6272d259 | |||
PERMISSIONS: | |||
android.permission.SEND_SMS ['dangerous', 'send SMS messages', 'Allows application to send SMS messages. Malicious applications may cost you money by sending messages without your confirmation.'] | |||
android.permission.READ_LOGS ['dangerous', 'read sensitive log data', "Allows an application to read from the system's various log files. This allows it to discover general information about what you are doing with the phone, potentially including personal or private information."] | |||
MAIN ACTIVITY: org.projectvoodoo.simplecarrieriqdetector.Main | |||
ACTIVITIES: ['org.projectvoodoo.simplecarrieriqdetector.Main'] | |||
SERVICES: [] | |||
RECEIVERS: [] | |||
PROVIDERS: [] | |||
Native code: False | |||
Dynamic code: False | |||
Reflection code: False | |||
Androcsign | |||
This tool helps you to create your own signatures in order to add them in the database. In fact, it's more easy after an analysis to isolate which parts are the more interesting to add in the database in order to detect the malware (and variants). So, the idea is to describe your signature of a malware in a json format file to add this signature to the database. | |||
desnos@destiny:~/androguard$ ./androcsign.py -h | |||
Usage: androcsign.py [options] | |||
Options: | |||
-h, --help show this help message and exit | |||
-i INPUT, --input=INPUT | |||
file : use this filename | |||
-r REMOVE, --remove=REMOVE | |||
remote the signature | |||
-o OUTPUT, --output=OUTPUT | |||
output database | |||
-l LIST, --list=LIST list signatures in database | |||
-c CHECK, --check=CHECK | |||
check signatures in database | |||
-v, --version version of the API | |||
The input file is a classical json format : | |||
[ { "SAMPLE" : "apks/malwares/DroidDream/Magic Hypnotic Spiral.apk" }, { "BASE" : "AndroidOS", "NAME" : "DroidDream", "SIGNATURE" : [ { "TYPE" : "METHSIM", "CN" : "Lcom/android/root/Setting;", "MN" : "postUrl", "D" : "(Ljava/lang/String; Landroid/content/Context;)V" } ], "BF" : "0" } ] | |||
where SAMPLE is the file where signatures will be extracted. NAME is the name of your signature. And SIGNATURE is a list of dictionnary which describes all sub-signatures. | |||
A sub-signature can be a : | |||
METHSIM : CN is the classname, NM is the method name, and D is the descriptor CLASSSIM : CN is the classname So a sub-signature can be apply on a specific method or directly on an entire class. | |||
BF is the boolean formula of the whole signature, so it's possible to mix different sub-signatures. | |||
When the sub-signature is added to the database, the engine will keep only interesting information : | |||
entropies of general signature, android packages, java packages, binary raw, and exceptions. These entropies are using to clustering sub-signatures and compare items : it is these values that which will be used to apply clustering, value of the general signature : it is this value that which will be used to apply similarity distance on each required cluster. In the previous output, we isolated one method (postUrl) in an application (droiddream malware) to create a new signature. Androcsign will extract useful information of this application to add the signature in the database : | |||
desnos@destiny:~/androguard$ ./androcsign.py -i signatures/droiddream.sign -o signatures/dbandroguard | |||
[{u'DroidDream': [[[0, 'QltTUDBQMVNTUDJQMlAwRjBQMVAxU1AxRjBQMVAxUDFQMVAxUDJQMFAxUDFQMVAxU1AxUDFQMFAxXUJbUDFJUDFdQltQMV | |||
Androdd | |||
This tool is used to output graphs for each method of each class of an Android package. | |||
$ ./androdd.py --help | |||
Usage: androdd.py [options] | |||
Options: | |||
-h, --help show this help message and exit | |||
-i INPUT, --input=INPUT | |||
file : use this filename | |||
-o OUTPUT, --output=OUTPUT | |||
base directory to output all files | |||
-d, --dot write the method in dot format | |||
-f FORMAT, --format=FORMAT | |||
write the method in specific format (png, ...) | |||
-v, --version version of the API | |||
input: an Android APK or classes.dex | |||
output directory is mandatory, or the tool does not output anything. | |||
output formats: PNG, JPG. | |||
if you wish both DOT and PNG output for ex, mix options -d and -f PNG | |||
Androdiff | |||
The tool is used to compare/display the differences between two apps. The documentation is available here | |||
Androdump | |||
BlogPost1 | |||
You can used it to dump a linux process in order to get the original class files. | |||
$ ./androdump.py -h | |||
Usage: androdump.py [options] | |||
Options: | |||
-h, --help show this help message and exit | |||
-i INPUT, --input=INPUT | |||
pid | |||
-v, --version version of the API | |||
pouik@camelot:~/androguard$ ps aux |grep java | |||
pouik 21008 0.1 0.5 673840 10688 pts/5 Sl+ 10:28 0:02 java Test2 | |||
pouik 21548 0.0 0.0 3060 812 pts/2 S+ 11:00 0:00 grep java | |||
pouik@camelot:~/androguard$ ./androdump.py -i 21008 | |||
HEADER 0x6f990000-0x6fee0000 (rw-p) | |||
Test2 ()V | |||
Test2 get_x ()I | |||
Test2 main ([Ljava/lang/String;)V | |||
Test2bis ()V | |||
Test2bis get_T ()Ljava/lang/String; | |||
Androgexf | |||
This tool outputs graphs using the GEXF format. | |||
desnos@destiny:~/androguard$ ./androgexf.py -h | |||
Usage: androgexf.py [options] | |||
Options: | |||
-h, --help show this help message and exit | |||
-i INPUT, --input=INPUT | |||
filename input (dex, apk) | |||
-o OUTPUT, --output=OUTPUT | |||
filename output of the xgmml | |||
For instance, | |||
desnos@destiny:~/androguard$ ./androgexf.py -i YOURAPP.apk -o YOURAPP.gexf | |||
The output graph can be viewed using an external tool, named Gephi. For real examples of visualization of Android malware, please see this page. | |||
Androlyze | |||
Androlyze is a tool to analyze Android applications. The most common features are available via command line, the others via a Python interactive shell: | |||
Usage: androlyze.py [options] | |||
Options: | |||
-h, --help show this help message and exit | |||
-i INPUT, --input=INPUT | |||
file : use this filename | |||
-d, --display display the file in human readable format | |||
-m METHOD, --method=METHOD | |||
display method(s) respect with a regexp | |||
-f FIELD, --field=FIELD | |||
display field(s) respect with a regexp | |||
-s, --shell open a shell to interact more easily with objects | |||
-v, --version version of the API | |||
-p, --pretty pretty print ! | |||
-t TYPE_PRETTY, --type_pretty=TYPE_PRETTY | |||
set the type of pretty print (0, 1) ! | |||
-x, --xpermissions show paths of permissions | |||
Using androlyze via the interactive shell opens up to tons of other features. Basically, all functions of the code are available that way: | |||
./androlyze.py -s | |||
Welcome to Androlyze ALPHA 0-update1 | |||
>>> j = JVMFormat( open("./VM.class").read() ) | |||
>>> j.show() | |||
# Get specific methods | |||
>>> x = j.get_method("<init>")[0] | |||
>>> x.show() | |||
# Change name | |||
>>> x.set_name("toto") | |||
# Save it | |||
>>> fd = open("VM2.class", "w") | |||
>>> fd.write(j.save()) | |||
>>> fd.close() | |||
Andromercury | |||
This tool links with the Mercury framework | |||
See blog post | |||
$ ./andromercury.py -h | |||
Usage: andromercury.py [options] | |||
Options: | |||
-h, --help show this help message and exit | |||
-l LIST, --list=LIST list all packages | |||
-i INPUT, --input=INPUT | |||
get specific packages (a filter) | |||
-r REMOTEHOST, --remotehost=REMOTEHOST | |||
specify ip of emulator/device | |||
-p PORT, --port=PORT specify the port | |||
-o OUTPUT, --output=OUTPUT | |||
output directory to write packages | |||
-b DATABASE, --database=DATABASE | |||
database : use this database | |||
-c CONFIG, --config=CONFIG | |||
use this configuration | |||
-v, --verbose display debug information | |||
Androrisk | |||
./androrisk.py -h | |||
Usage: androrisk.py [options] | |||
Options: | |||
-h, --help show this help message and exit | |||
-i INPUT, --input=INPUT | |||
file : use these filenames | |||
-a, --analysis perform analysis to calculate the risk | |||
-m, --method perform analysis of each method | |||
-d DIRECTORY, --directory=DIRECTORY | |||
directory : use this directory | |||
-v, --version version of the API | |||
Androsign | |||
Checks whether a given sample is listed in the database or not. | |||
$ ./androsign.py -h | |||
Usage: androsign.py [options] | |||
Options: | |||
-h, --help show this help message and exit | |||
-i INPUT, --input=INPUT | |||
file : use this filename | |||
-d DIRECTORY, --directory=DIRECTORY | |||
directory : use this directory | |||
-b DATABASE, --database=DATABASE | |||
database : use this database | |||
-c CONFIG, --config=CONFIG | |||
use this configuration | |||
-v, --verbose display debug information | |||
For example, see http://code.google.com/p/androguard/wiki/AndroidMalwareAnalysis: | |||
$ ./androsign.py -d apks/malwares/foncy/ -b signatures/dbandroguard -c signatures/dbconfig | |||
98a402d885cdb941dca8b45a4bbcbbe7f44ba62910d519bc1c2161dba117ebd2 : ----> Foncy | |||
81dd17ea168cf884bfb5aebb7cd2241a5624d1ae14444594bf7677e1080339f9 : ----> Foncy | |||
d9ef940236f285548a60be0d575d7bba4587bdfc3f6c56f38b5da601686344a9 : ----> Foncy | |||
SuiConFo 1.26.apk : ----> None | |||
127sc.apk : ----> None | |||
Androsim | |||
The tool is used to get the similarities between two apps. The documentation is available here | |||
axelle@caiman:~/softs/androguard$ ./androsim.py -h | |||
Usage: androsim.py [options] | |||
Options: | |||
-h, --help show this help message and exit | |||
-i INPUT, --input=INPUT | |||
file : use these filenames | |||
-t THRESHOLD, --threshold=THRESHOLD | |||
define the threshold | |||
-c COMPRESSOR, --compressor=COMPRESSOR | |||
define the compressor | |||
-d, --display display all information about methods | |||
-n, --new don't calculate the similarity score with new methods | |||
-e EXCLUDE, --exclude=EXCLUDE | |||
exclude specific class name (python regexp) | |||
-s SIZE, --size=SIZE exclude specific method below the specific size | |||
-x, --xstrings display similarities of strings | |||
-v, --version version of the API | |||
-l LIBRARY, --library=LIBRARY | |||
use python library (python) or specify the path of the | |||
shared library) | |||
Androxgmml | |||
BlogPost1 | |||
You can used it to transform an apk/jar/class/dex files format into an xgmml graph which represent the control flow graph or the functions call. | |||
$ ./androxgmml.py -h | |||
Usage: androxgmml.py [options] | |||
Options: | |||
-h, --help show this help message and exit | |||
-i INPUT, --input=INPUT | |||
filename input | |||
-o OUTPUT, --output=OUTPUT | |||
filename output of the xgmml | |||
-f, --functions include function calls | |||
-e, --externals include extern function calls | |||
-v, --version version of the API | |||
./androxgmml.py -i myapp.jar -o output.xgmml | |||
./androxgmml.py -i myapp.apk -o output.xgmml | |||
./androxgmml.py -i myclass.class -o output.xgmml | |||
./androxgmml.py -i mydex.dex -o output.xgmml | |||
# with functions call : | |||
./androxgmml.py -i myapp.jar -f -o output.xgmml | |||
# with external function calls | |||
./androxgmml.py -i myapp.jar -e -o output.xgmml | |||
# with both | |||
./androxgmml.py -i myapp.jar -e -f -o output.xgmml | |||
Apkviewer | |||
./apkviewer.py -h | |||
Usage: apkviewer.py [options] | |||
Options: | |||
-h, --help show this help message and exit | |||
-i INPUT, --input=INPUT | |||
filename input (dex, apk) | |||
-o OUTPUT, --output=OUTPUT | |||
directory output | |||
@ -0,0 +1,498 @@ | |||
Copy/pasted from [https://github.com/pwntester/cheatsheets/blob/master/radare2.md](https://github.com/pwntester/cheatsheets/blob/master/radare2.md) | |||
Radare2 | |||
Command line options | |||
-L: List of supported IO plugins | |||
-q: Exit after processing commands | |||
-w: Write mode enabled | |||
-i: Interprets a r2 script | |||
-A: Analize executable at load time (xrefs, etc) | |||
-n: Bare load. Do not load executable info as the entrypoint | |||
-c'cmds': Run r2 and execute commands (eg: r2 -wqc'wx 3c @ main') | |||
-p: Creates a project for the file being analyzed (CC add a comment when opening a file as a project) | |||
-: Opens r2 with the malloc plugin that gives a 512 bytes memory area to play with (size can be changed) | |||
Similar to r2 malloc://512 | |||
Configuration properties | |||
They can be used in evaluations:? ${asm.tabs} | |||
e: Returs configuration properties | |||
e <property>: Checks a specific property: | |||
e asm.tabs => false | |||
e <property>=<value>: Change property value | |||
e asm.arch=ppc | |||
e? help about a configuration property | |||
e? cmd.stack | |||
You will want to set your favourite options in ~/.radare2rc since every line there will be interpreted at the beginning of each session. Mine for reference: | |||
# Show comments at right of disassembly if they fit in screen | |||
e asm.cmtright=true | |||
# Shows pseudocode in disassembly. Eg mov eax, str.ok = > eax = str.ok | |||
e asm.pseudo = true | |||
# Display stack and register values on top of disasembly view (visual mode) | |||
e cmd.stack = true | |||
# Solarized theme | |||
eco solarized | |||
# Use UTF-8 to show cool arrows that do not look like crap :) | |||
e scr.utf8 = true | |||
There is an easier interface accessible from the Visual mode, just typing Ve | |||
Basic Commands | |||
Command syntax: [.][times][cmd][~grep][@[@iter]addr!size][|>pipe] | |||
; Command chaining: x 3;s+3;pi 3;s+3;pxo 4; | |||
| Pipe with shell commands: pd | less | |||
! Run shell commands: !cat /etc/passwd | |||
!! Escapes to shell, run command and pass output to radare buffer | |||
Note: The double exclamation mark tells radare to skip the plugin list to find an IO plugin handling this command to launch it directly to the shell. A single one will walk through the io plugin list. | |||
` Radare commands: wx `!ragg2 -i exec` | |||
~ grep | |||
~! grep -v | |||
~[n] grep by columns afl~[0] | |||
~:n grep by rows afl~:0 | |||
pi~mov,eax ; lines with mov or eax | |||
pi~mov&eax ; lines with mov and eax | |||
pi~mov,eax:6 ; 6 first lines with mov or eax | |||
pd 20~call[0]:0 ; grep first column of the first row matching 'call' | |||
.cmd Interprets command output | |||
is* prints symbolos | |||
.is* interprets output and define the symbols in radare (normally they are already loaded if r2 was not invoked with -n) | |||
.. repeats last commands (same as enter \n) | |||
( Used to define and run macros | |||
$ Used to define alias | |||
$$: Resolves to current address | |||
Offsets (@) are absolute, we can use $$ for relative ones @ $$+4 | |||
? Evaluate expression | |||
[0x00000000]> ? 33 +2 | |||
35 0x23 043 0000:0023 35 00100011 35.0 0.000000 | |||
Note: | and & need to be escaped | |||
?$? Help for variables used in expressions | |||
$$: Here | |||
$s: File size | |||
$b: Block size | |||
$l: Opcode length | |||
$j: When $$ is at a jmp, $j is the address where we are going to jump to | |||
$f: Same for jmp fail address | |||
$m: Opcode memory reference (e.g. mov eax,[0x10] => 0x10) | |||
??? Help for ? command | |||
?i Takes input from stdin. Eg ?i username | |||
?? Result from previous operations | |||
?s from to [step]: Generates sequence from to every | |||
?p: Get physical address for given virtual address | |||
?P: Get virtual address for given physical one | |||
?v Show hex value of math expr | |||
?v 0x1625d4ca ^ 0x72ca4247 = 0x64ef968d | |||
?v 0x4141414a - 0x41414140 = 0xa | |||
?l str: Returns the length of string | |||
@@: Used for iteractions | |||
wx ff @@10 20 30 Writes ff at offsets 10, 20 and 30 | |||
wx ff @@`?s 1 10 2` Writes ff at offsets 1, 2 and 3 | |||
wx 90 @@ sym.* Writes a nop on every symbol | |||
Positioning | |||
s address: Move cursor to address or symbol | |||
s-5 (5 bytes backwards) | |||
s- undo seek | |||
s+ redo seek | |||
Block size | |||
The block size is the default view size for radare. All commands will work with this constraint, but you can always temporally change the block size just giving a numeric argument to the print commands for example (px 20) | |||
b size: Change block size | |||
JSON Output | |||
Most of commands such as (i)nfo and (p)rint commands accept a j to print their output in json | |||
[0x100000d78]> ij | |||
{"bin":{"type":"mach0","class":"MACH064","endian":"little","machine":"x86 64 all","arch":"x86","os":"osx","lang":"c","pic":true,"canary":false,"nx":false,"crypto":false,"va":true,"bits":64,"stripped":true,"static":false,"linenums":false,"syms":false,"relocs":false},"core":{"type":"Executable file","os":"osx","arch":"x86 64 all","bits":64,"endian":"little","file":"/bin/ls","fd":6,"size":34640,"mode":"r--","block":256,"uri":"/bin/ls","format":"mach064"}} | |||
Analyze | |||
aa: Analyze all (fcns + bbs) same that running r2 with -A | |||
ahl <length> <range>: fake opcode length for a range of bytes | |||
ad: Analyze data | |||
ad@rsp (analize the stack) | |||
Function analysis (normal mode) | |||
af: Analyze functions | |||
afl: List all functions | |||
number of functions: afl~? | |||
afi: Returns information about the functions we are currently at | |||
afr: Rename function: structure and flag | |||
afr off: Restore function name set by r2 | |||
afn: Rename function | |||
afn strlen 0x080483f0 | |||
af-: Removes metadata generated by the function analysis | |||
af+: Define a function manually given the start address and length | |||
af+ 0xd6f 403 checker_loop | |||
axt: Returns cross references to (xref to) | |||
axf: Returns cross references from (xref from) | |||
Function analysis (visual mode) | |||
d, f: Function analysis | |||
d, u: Remove metadata generated by function analysis | |||
Opcode analysis: | |||
ao x: Analize x opcodes from current offset | |||
a8 bytes: Analize the instruction represented by specified bytes | |||
Information | |||
iI: File info | |||
iz: Strings in data section | |||
izz: Strings in the whole binary | |||
iS: Sections | |||
iS~w returns writable sections | |||
is: Symbols | |||
is~FUNC exports | |||
il: Linked libraries | |||
ii: Imports | |||
ie: Entrypoint | |||
Mitigations: | |||
i~pic : check if the binary has position-independent-code | |||
i~nx : check if the binary has non-executable stack | |||
i~canary : check if the binary has canaries | |||
Get function address in GOT table: pd 1 @ sym.imp<funct> Returns a jmp [addr] where addr is the the address of function in the GOT. Similar to objdump -R | grep <func> | |||
psz n @ offset: Print n zero terminated String | |||
px n @ offset: Print hexdump (or just x) of n bytes | |||
pxw n @ offset: Print hexdump of n words | |||
pxw size@offset prints hexadecimal words at address | |||
pd n @ offset: Print n opcodes disassambled | |||
pD n @ offset: Print n bytes disassembled | |||
pi n @ offset: Print n instructions disassambeled (no address, XREFs, etc. just instrunctions) | |||
pdf @ offset: Print disassembled function | |||
pdf~XREF (grep: XREFs) | |||
pdf~call (grep: calls) | |||
pcp n @ offset: Print n bytes in python string output. | |||
pcp 0x20@0x8048550 | |||
import struct | |||
buf = struct.pack ("32B", | |||
0x55,0x89,0xe5,0x83,0xzz,0xzz,0xzz,0xzz,0xf0,0x00,0x00, | |||
0x00,0x00,0xc7,0x45,0xf4,0x00,0x00,0x00,0x00,0xeb,0x20, | |||
0xc7,0x44,0x24,0x04,0x01,0x00,0x00,0x00,0xzz,0xzz) | |||
p8 n @ offset: Print n bytes (8bits) (no hexdump) | |||
pv: Print file contents as IDA bar and shows metadata for each byte (flags , ...) | |||
pt: Interpret data as dates | |||
pf: Print with format | |||
pf.: list all formats | |||
p=: Print entropy ascii graph | |||
Write | |||
wx: Write hex values in current offset | |||
wx 123456 | |||
wx ff @ 4 | |||
wa: Write assembly | |||
wa jnz 0x400d24 | |||
wc: Write cache commit | |||
wv: Writes value doing endian conversion and padding to byte | |||
wo[x]: Write result of operation | |||
wow 11223344 @102!10 | |||
write looped value from 102 to 102+10 | |||
0x00000066 1122 3344 1122 3344 1122 0000 0000 0000 | |||
wox 0x90 | |||
XOR the current block with 0x90. Equivalent to wox 0x90 $$!$b (write from current position, a whole block) | |||
wox 67 @4!10 | |||
XOR from offset 4 to 10 with value 67 | |||
wf file: Writes the content of the file at the current address or specified offset (ASCII characters only) | |||
wF file: Writes the content of the file at the current address or specified offset | |||
wt file [sz]: Write to file (from current seek, blocksize or sz bytes) | |||
Eg: Dump ELF files with wt @@ hit0* (after searching for ELF headers: \x7fELF) | |||
woO 41424344 : get the index in the De Bruijn Pattern of the given word | |||
Flags | |||
Flags are labels for offsets. They can be grouped in namespaces as sym for symbols ... | |||
f: List flags | |||
f label @ offset: Define a flag `label` at offset | |||
f str.pass_len @ 0x804999c | |||
f -label: Removes flag | |||
fr: Rename flag | |||
fd: Returns position from nearest flag (looking backwards). Eg => entry+21 | |||
fs: Show all flag spaces | |||
fs flagspace: Change to the specified flag space | |||
yank & paste | |||
y n: Copies n bytes from current position | |||
y: Shows yank buffer contentent with address and length where each entry was copied from | |||
yp: Prints yank buffer | |||
yy offset: Paste the contents of the yank buffer at the specified offset | |||
yt n target @ source: Yank to. Copy n bytes fromsource to target address | |||
Visual Mode: | |||
V enters visual mode | |||
q: Exits visual mode | |||
hjkl: move around (or HJKL) (left-down-up-right) | |||
o: go/seek to given offset | |||
?: Help | |||
.: Seek EIP | |||
<enter>: Follow address of the current jump/call | |||
:cmd: Enter radare commands. Eg: x @ esi | |||
d[f?]: Define cursor as a string, data, code, a function, or simply to undefine it. | |||
dr: Rename a function | |||
df: Define a function | |||
v: Get into the visual code analysis menu to edit/look closely at the current function. | |||
p/P: Rotate print (visualization) modes | |||
hex, the hexadecimal view | |||
disasm, the disassembly listing | |||
Use numbers in [] to follow jump | |||
Use "u" to go back | |||
debug, the debugger | |||
words, the word-hexidecimal view | |||
buf, the C-formatted buffer | |||
annotated, the annotated hexdump. | |||
c: Changes to cursor mode or exits the cursor mode | |||
select: Shift+[hjkl] | |||
i: Insert mode | |||
a: assembly inline | |||
A: Assembly in visual mode | |||
y: Copy | |||
Y: Paste | |||
f: Creates a flag where cursor points to | |||
<tab> in the hexdump view to toggle between hex and strings columns | |||
V: View ascii-art basic block graph of current function | |||
W: WebUI | |||
x, X: XREFs to current function. ("u" to go back) | |||
t: track flags (browse symbols, functions..) | |||
gG: Begging or end of file | |||
HUD | |||
_ Show HUD | |||
backspace: Exits HUD | |||
We can add new commands to HUD in: radare2/shlr/hud/main | |||
;[-]cmt: Add/remove comment | |||
m<char>: Define a bookmark | |||
'<char>: Go to previously defined bookmark | |||
ROP | |||
/R opcodes: Search opcodes | |||
/R pop,pop,ret | |||
/Rl opcodes: Search opcodes and print them in linear way | |||
/Rl jmp eax,call ebx | |||
/a: Search assembly | |||
/a jmp eax | |||
pda: Returns a library of gadgets that can be use. These gadgets are obtained by disassmbling byte per byte instead of obeying to opcode length | |||
Search depth can be configure with following properties: | |||
e search.roplen = 4 (change the depth of the search, to speed-up the hunt) | |||
Searching | |||
/ bytes: Search bytes | |||
\x7fELF | |||
Example: Searching function preludes: | |||
push ebp | |||
mov ebp, esp | |||
Opcodes: 5589e5 | |||
/x 5589e5 | |||
[# ]hits: 54c0f4 < 0x0804c600 hits = 1 | |||
0x08049f70 hit0_0 5589e557565383e4f081ec | |||
0x0804c31a hit0_1 5589e583ec18c704246031 | |||
0x0804c353 hit0_2 5589e583ec1889442404c7 | |||
0x0804c379 hit0_3 5589e583ec08e87cffffff | |||
0x0804c3a2 hit0_4 5589e583ec18c70424302d | |||
pi 5 @@hit* (Print 5 first instructions of every hit) | |||
Its possible to run a command for each hit. Use the cmd.hit property: | |||
e cmd.hit=px | |||
Comments and defines | |||
Cd [size]: Define as data | |||
C- [size]: Define as code | |||
Cs [size]: Define as String | |||
Cf [size]: Define as struct | |||
We can define structures to be shown in the disassmbly | |||
CC: List all comments or add a new comment in console mode | |||
C* Show all comments/metadata | |||
CC <comment> add new comment | |||
CC- remove comment | |||
Magic files | |||
pm: Print Magic files analysis | |||
[0x00000000]> pm | |||
0x00000000 1 ELF 32-bit LSB executable, Intel 80386, version 1 | |||
Search for magic numbers | |||
/m [magicfile]: Search magic number headers with libmagic | |||
Search can be controlled with following properties: | |||
search.align | |||
search.from (0 = beginning) | |||
search.to (0 = end) | |||
search.asmstr | |||
search.in | |||
Yara | |||
Yara can also be used for detecting file signatures to determine compiler types, shellcodes, protections and more. | |||
:yara scan | |||
Zignatures | |||
Zignatures are useful when dealing with stripped binaries. We can take a non-stripped binary, run zignatures on it and apply it to a different binary that was compiled statically with the same libraries. | |||
zg <language> <output file>: Generate signatures | |||
eg: zg go go.z | |||
Run the generated script to load signatures | |||
eg: . go.z | |||
z: To show signatures loaded: | |||
Zignatures are applied as comments: | |||
r2-(pid2)> pd 35 @ 0x08049adb-10 | |||
| 0x08049adb call fcn.0805b030 | |||
| fcn.0805b030(unk, unk, unk, unk) ; sign.sign.b.sym.fmt.Println | |||
| 0x08049ae0 add esp, 0xc | |||
| 0x08049ae3 call fcn.08095580 | |||
Compare files | |||
r2 -m 0xf0000 /etc/fstab ; Open source file | |||
o /etc/issue ; Open file2 at offset 0 | |||
o ; List both files | |||
cc offset: Diff by columns between current offset address and "offset" | |||
Graphs | |||
Basic block graphs | |||
af: Load function metadata | |||
ag $$ > a.dot: Dump basic block graph to file | |||
ag $$ | xdot: Show current function basic block graph | |||
Call graphs | |||
af: Load function metadata | |||
agc $$ > b.dot: Dump basic block graph to file | |||
Convert .dot in .png | |||
dot -Tpng -o /tmp/b.png b.dot | |||
Generate graph for file: | |||
radiff2 -g main crackme.bin crackme.bin > /tmp/a | |||
xdot /tmp/a | |||
Debugger | |||
Start r2 in debugger mode. r2 will fork and attach | |||
r2 -d [pid|cmd|ptrace] (if command contains spaces use quotes: r2 -d "ls /") | |||
ptrace://pid (debug backend does not notice, only access to mapped memory) | |||
To pass arguments: | |||
r2 -d rarun2 program=pwn1 arg1=$(python exploit.py) | |||
To pass stdin: | |||
r2 -d rarun2 program=/bin/ls stdin=$(python exploit.py) | |||
Commands | |||
do: Reopen program | |||
dp: Shows debugged process, child processes and threads | |||
dc: Continue | |||
dcu <address or symbol>: Continue until symbol (sets bp in address, continua until bp and remove bp) | |||
dc[sfcp]: Continue until syscall(eg: write), fork, call, program address (To exit a library) | |||
ds: Step in | |||
dso: Step out | |||
dss: Skip instruction | |||
dr register=value: Change register value | |||
dr(=)?: Show register values | |||
db address: Sets a breakpoint at address | |||
db sym.main add breakpoint into sym.main | |||
db 0x804800 add breakpoint | |||
db -0x804800 remove breakpoint | |||
dsi (conditional step): Eg: "dsi eax==3,ecx>0" | |||
dbt: Shows backtrace | |||
drr: Display in colors and words all the refs from registers or memory | |||
dm: Shows memory map (* indicates current section) | |||
[0xb776c110]> dm | |||
sys 0x08048000 - 0x08062000 s r-x /usr/bin/ls | |||
sys 0x08062000 - 0x08064000 s rw- /usr/bin/ls | |||
sys 0xb776a000 - 0xb776b000 s r-x [vdso] | |||
sys 0xb776b000 * 0xb778b000 s r-x /usr/lib/ld-2.17.so | |||
sys 0xb778b000 - 0xb778d000 s rw- /usr/lib/ld-2.17.so | |||
sys 0xbfe5d000 - 0xbfe7e000 s rw- [stack] | |||
To follow child processes in forks (set-follow-fork-mode in gdb) | |||
dcf until a fork happen | |||
then use dp to select what process you want to debug. | |||
PEDA like details: drr;pd 10@-10;pxr 40@esp | |||
Debug in visual mode | |||
toggl breakpoints with F2 | |||
single-step with F7 (s) | |||
step-over with F8 (S) | |||
continue with F9 | |||
WebGUI (Enyo) | |||
=h: Start the server | |||
=H: Start server and browser | |||
Radare2 suite commandRadare2 suite commands | |||
All suite commands include a -r flag to generate instructions for r2 | |||
rax2 - Base conversion | |||
-e: Change endian | |||
-k: random ASCII art to represent a number/hash. Similar to how SSH represents keys | |||
-s: ASCII to hex | |||
rax2 -S hola (from string to hex) | |||
rax2 -s 686f6c61 (from hex to string) | |||
-S: binary to hex (for files) | |||
rahash2 - Entropy, hashes and checksums | |||
-a: Specify the algorithm | |||
-b XXX: Block size | |||
-B: Print all blocks | |||
-a entropy: Show file entropy or entropy per block (-B -b 512 -a entropy) | |||
radiff2 - File diffing | |||
-s: Calculate text distance from two files. | |||
-d: Delta diffing (For files with different sizes. Its not byte per byte) | |||
-C: Code diffing (instead of data) | |||
Examples: | |||
Diff original and patched on x86_32, using graphdiff algorithm | |||
radiff2 -a x86 -b32 -C original patched | |||
Show differences between original and patched on x86_32 | |||
radiff2 -a x86 -b32 original patched : | |||
rasm2 - Assembly/Disassembly | |||
-L: Supported architectures | |||
-a arch instruction: Sets architecture | |||
rasm2 -a x86 'mov eax,30' => b81e000000 | |||
-b tam: Sets block size | |||
-d: Disassembly | |||
rasm2 -d b81e000000 => mov eax, 0x1e | |||
-C: Assembly in C output | |||
rasm2 -C 'mov eax,30' =>"\xb8\x1e\x00\x00\x00" | |||
-D: Disassemble showing hexpair and opcode | |||
rasm2 -D b81e0000 => 0x00000000 5 b81e000000 mov eax, 0x1e | |||
-f: Read data from file instead of ARG. | |||
-t: Write data to file | |||
rafind2 - Search | |||
-Z: Look for Zero terminated strings | |||
-s str: Look for specifc string | |||
ragg2 - Shellcode generator, C/opcode compiler | |||
-P: Generate De Bruijn patterns | |||
ragg2 -P 300 -r | |||
-a arch: Configure architecture | |||
-b bits: Specify architecture bits (32/64) | |||
-i shellcode: Specify shellcode to generate | |||
-e encoder: Specify encoder | |||
Example: | |||
Generate a x86, 32 bits exec shellcode | |||
ragg2 -a x86 -b 32 -i exec | |||
rabin2 - Executable analysis: symbols, imports, strings ... | |||
-I: Executable information | |||
-C: Returns classes. Useful to list Java Classes | |||
-l: Dynamic linked libraries | |||
-s: Symbols | |||
-z: Strings | |||
rarun2 - Launcher to run programs with different environments, args, stdin, permissions, fds | |||
Examples: | |||
r2 -b 32 -d rarun2 program=pwn1 arg1=$(ragg2 -P 300 -r) : runs pwn1 with a De Bruijn Pattern as first argument, inside radare2's debugger, and force 32 bits | |||
r2 -d rarun2 program=/bin/ls stdin=$(python exploit.py) : runs /bin/ls with the output of exploit.py directed to stdin | |||
@ -0,0 +1,43 @@ | |||
##Information Security Conference Videos & Stuff | |||
[31st Chaos Communication Congress Archive](http://cdn.media.ccc.de/congress/31C3/) | |||
[Shmoocon 2015 Videos](https://archive.org/details/shmoocon-2015-videos-playlist) | |||
[Defcon Media Archive](https://media.defcon.org/) | |||
[You and Your Research - Haroon Meer](https://www.youtube.com/watch?v=JoVx_-bM8Tg) | |||
* What does it take to do quality research? What stops you from being a one-hit wonder? Is there an age limit to productive hackery? What are the key ingredients needed and how can you up your chances of doing great work? In a talk unabashedly stolen from far greater minds we hope to answer these questions and discuss their repercussions. | |||
[A talk about (info-sec) talks - Haroon Meer ](https://www.youtube.com/watch?v=BlVjdUkrSFY) | |||
* Last year there was an Information Security conference taking place for almost every day of the year. This translates to about 15 information security talks per day, every day. The question is, is this a bad thing? Even niche areas of the info-sec landscape have their own dedicated conference these days. Is this a good thing? | |||
[Archive of security conference videos](http://wipkip.nikhef.nl/events/) | |||
[Trooper Conference - 2015](https://www.youtube.com/channel/UCPY5aUREHmbDO4PtR6AYLfQ) | |||
###Slides/PDFs | |||
[CanSecWest Vancouver 2015 Slides](https://cansecwest.com/csw15archive.html) | |||
[SyScan2015 Slides](https://www.syscan.org/index.php/download) | |||
@ -0,0 +1,34 @@ | |||
##Disinformation | |||
###Talks | |||
[Governments and UFOs: A Historical Analysis of Disinformation and Deception - Richard Thieme](http://www.irongeek.com/i.php?page=videos/bsideslasvegas2013/1-2-7-governments-and-ufos-a-historical-analysis-of-disinformation-and-deception-richard-thieme) | |||
[[TROOPERS15] Azhar Desai, Marco Slaviero - Weapons of Mass Distraction](https://www.youtube.com/watch?v=jdaPJLJCK1M) | |||
###Papers/Write-ups | |||
[The Gentleperson’s Guide to Forum Spies]cryptome.org/2012/07/gent-forum-spies.htm) | |||
[Attribution As A Weapon & Marketing Tool: Hubris In INFOSEC & NATSEC](https://krypt3ia.wordpress.com/2014/12/30/attribution-as-a-weapon-marketing-tool-hubris-in-infosec-natsec/) | |||
[Disinformation of Charlie Hebdo and The Fake BBC Website](http://thetrendythings.com/read/18256) | |||
[Counterintelligence, False Flags, Disinformation, and Network Defense - krypt3ia](https://krypt3ia.wordpress.com/2012/10/17/counterintelligence-false-flags-disinformation-and-network-defense/) | |||
[PsyOps and Socialbots](http://resources.infosecinstitute.com/psyops-and-socialbots/) | |||
[A Digital World Full of Ghost Armies](http://www.cigtr.info/2015/02/a-digital-world-full-of-ghost-armies.html) | |||
* Not very related to infosec per say, but the general idea/takeaway is very applicable. | |||
[Russia Convention on International Information Security](http://cryptome.org/2014/05/ru-international-infosec.htm) | |||
@ -0,0 +1,98 @@ | |||
##Documentation & Reporting | |||
For writing technical documentation. | |||
Writing | |||
Reports | |||
Meta | |||
Video Documentation | |||
###Penetration Testing &/ Collaboration Tools | |||
[Kvasir](https://github.com/KvasirSecurity/Kvasir) | |||
* Kvasir is a vulnerability / penetration testing data management system designed to help mitigate the issues found when performing team-based assessments. Kvasir does this by homogenizing data sources into a pre-defined structure. Currently the following sources are supported: | |||
[Dradis](https://github.com/dradis/dradisframework#welcome-to-dradis) | |||
* Dradis is an open source collaboration framework, tailored to InfoSec teams. | |||
* It can integrate with a lot of existing tools you probably are using if you're reading this. | |||
[Faraday](https://github.com/infobyte/faraday) | |||
* Faraday introduces a new concept (IPE) Integrated Penetration-Test Environment a multiuser Penetration test IDE. Designed for distribution, indexation and analysis of the generated data during the process of a security audit. The main purpose of Faraday is to re-use the available tools in the community to take advantage of them in a multiuser way.1 | |||
[Lair](https://github.com/lair-framework/lair) | |||
* Lair is a reactive attack collaboration framework and web application built with meteor. | |||
##Writing | |||
Start with the first two links, and go from there. They’re both great resources to writing technical documentation, the first being a beginners guide and the second being a general guide that beginners can understand. | |||
[A beginners guide to writing documentation](http://docs.writethedocs.org/writing/beginners-guide-to-docs/) | |||
[Teach, Don’t Tell](http://stevelosh.com/blog/2013/09/teach-dont-tell/) | |||
Other Materials: | |||
Three parter from jacobian.org: | |||
* [What to write](http://jacobian.org/writing/what-to-write/) | |||
* [Technical Style](http://jacobian.org/writing/technical-style/) | |||
* [Editors](http://jacobian.org/writing/editors/) | |||
[Writing Types of User Documentation](https://en.wikiversity.org/wiki/Technical_writing_Types_of_User_Documentation0 | |||
[The 7 Rules for Writing World Class Technical Documentation](http://www.developer.com/tech/article.php/3848981/The-7-Rules-for-Writing-World-Class-Technical-Documentation.htm) | |||
###Writing Reports | |||
[Penetration tests done by cure53, good examples of how a report should be done.](https://cure53.de/#publications ) | |||
[Offensive Security 2013 Demo report](http://www.offensive-security.com/offsec/penetration-test-report-2013/) | |||
[Writing a Penetration Testing Report by SANS](https://www.sans.org/reading-room/whitepapers/bestprac/writing-penetration-testing-report-33343) | |||
[Excellent blog post breaking down the various parts, a must read](http://wwwwebsecuritywatch.com/the-penetration-testing-report/) | |||
[Report Template from vulnerabilityassessment.co.uk](http://www.vulnerabilityassessment.co.uk/report%20template.html) | |||
[Penetration Testing Execution Standard section on Reporting](http://www.pentest-standard.org/index.php/Reporting) | |||
[security-assessment-rfp-cheat-sheet](http://zeltser.com/security-assessments/security-assessment-rfp-cheat-sheet.html) | |||
[Tips for Creating an Information Security Assessment Report Cheat Sheet](https://zeltser.com/security-assessment-report-cheat-sheet/) | |||
[SANS InfoSec Policy Templates](https://www.sans.org/security-resources/policies/) | |||
###Meta | |||
[What is Markdown?](http://daringfireball.net/projects/markdown/syntax) | |||
[Using markdown](https://guides.github.com/features/mastering-markdown/) | |||
[Markdown Syntax](http://daringfireball.net/projects/markdown/syntax) | |||
[Markdown basics](https://help.github.com/articles/markdown-basics/) | |||
[Mastering Markdown](https://guides.github.com/features/mastering-markdown/) | |||
###Video Recording | |||
[Open Broadcaster Software OBS](https://obsproject.com/) | |||
* Open Broadcaster Software is free and open source software for video recording and live streaming. | |||
* Cross Platform, Windows/OsX/Linux | |||