forked from bitvijays/bitvijays.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLFCForensics.html
More file actions
257 lines (246 loc) · 16.4 KB
/
LFCForensics.html
File metadata and controls
257 lines (246 loc) · 16.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-92365403-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<title>Learning from the CTF : Forensics — tech.bitvijays.com</title>
<link rel="stylesheet" href="_static/sphinxdoc.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '0.1',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="search" title="Search" href="search.html" />
<link rel="top" title="tech.bitvijays.com" href="index.html" />
<link rel="next" title="Learning from the CTF : Cryptography" href="LFCCryptography.html" />
<link rel="prev" title="Learning from the CTF : Binary Exploitation" href="LFCBinaryExploitation.html" />
</head>
<body role="document">
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="LFCCryptography.html" title="Learning from the CTF : Cryptography"
accesskey="N">next</a></li>
<li class="right" >
<a href="LFCBinaryExploitation.html" title="Learning from the CTF : Binary Exploitation"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">tech.bitvijays.com</a> »</li>
</ul>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h4>Previous topic</h4>
<p class="topless"><a href="LFCBinaryExploitation.html"
title="previous chapter">Learning from the CTF : Binary Exploitation</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="LFCCryptography.html"
title="next chapter">Learning from the CTF : Cryptography</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/LFCForensics.txt"
rel="nofollow">Show Source</a></li>
<li><a href="https://github.com/bitvijays/bitvijays.github.io-sphinx/blob/master/docs/LFCForensics.rst"
rel="nofollow">Show on GitHub</a></li>
<li><a href="https://github.com/bitvijays/bitvijays.github.io-sphinx/edit/master/docs/LFCForensics.rst"
rel="nofollow">Edit on GitHub</a></li>
</ul>
<div id="searchbox" style="display: none" role="search">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<div><input type="text" name="q" /></div>
<div><input type="submit" value="Go" /></div>
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="learning-from-the-ctf-forensics">
<h1>Learning from the CTF : Forensics<a class="headerlink" href="#learning-from-the-ctf-forensics" title="Permalink to this headline">¶</a></h1>
<p>This post (Work in Progress) lists the tips and tricks while doing Forensics challenges during various CTF’s.</p>
<ul class="simple">
<li>If you are provided a jar file in the challenge, JAR (Java ARchive) is a package file format typically used to aggregate many Java class files and associated metadata and resources (text, images, etc.) into one file to distribute application software or libraries on the Java platform. It can be extracted using</li>
</ul>
<blockquote>
<div><div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">jar</span> <span class="n">xf</span> <span class="n">jar</span><span class="o">-</span><span class="n">file</span>
<span class="n">x</span> <span class="p">:</span> <span class="n">extract</span> <span class="n">files</span> <span class="kn">from</span> <span class="nn">the</span> <span class="n">JAR</span> <span class="n">archive</span><span class="o">.</span>
<span class="n">f</span> <span class="p">:</span> <span class="n">JAR</span> <span class="n">file</span> <span class="kn">from</span> <span class="nn">which</span> <span class="n">files</span> <span class="n">are</span> <span class="n">to</span> <span class="n">be</span> <span class="n">extracted</span> <span class="ow">is</span> <span class="n">specified</span> <span class="n">on</span> <span class="n">the</span> <span class="n">command</span> <span class="n">line</span><span class="p">,</span> <span class="n">rather</span> <span class="n">than</span> <span class="n">through</span> <span class="n">stdin</span><span class="o">.</span>
<span class="n">The</span> <span class="n">jar</span><span class="o">-</span><span class="n">file</span> <span class="n">argument</span> <span class="ow">is</span> <span class="n">the</span> <span class="n">filename</span> <span class="p">(</span><span class="ow">or</span> <span class="n">path</span> <span class="ow">and</span> <span class="n">filename</span><span class="p">)</span> <span class="n">of</span> <span class="n">the</span> <span class="n">JAR</span> <span class="n">file</span> <span class="kn">from</span> <span class="nn">which</span> <span class="n">to</span> <span class="n">extract</span> <span class="n">files</span><span class="o">.</span>
</pre></div>
</div>
</div></blockquote>
<ul class="simple">
<li>Wireshark - Searching for answers in pcap file?</li>
</ul>
<blockquote>
<div><ul class="simple">
<li>Searching passwords in HTTP Web traffic in wireshark?</li>
</ul>
<blockquote>
<div><div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">http</span><span class="o">.</span><span class="n">request</span><span class="o">.</span><span class="n">method</span> <span class="o">==</span> <span class="s2">"POST"</span> <span class="nb">filter</span> <span class="n">might</span> <span class="n">help</span><span class="p">,</span> <span class="n">based</span> <span class="n">on</span> <span class="n">concept</span> <span class="n">that</span> <span class="n">server</span> <span class="ow">is</span> <span class="n">asking</span> <span class="k">for</span> <span class="n">LOGIN</span> <span class="n">prompt</span> <span class="ow">and</span> <span class="n">user</span> <span class="ow">is</span> <span class="n">POSTing</span> <span class="n">his</span> <span class="n">password</span> <span class="ow">in</span> <span class="n">cleartext</span><span class="o">.</span>
</pre></div>
</div>
</div></blockquote>
<ul class="simple">
<li>If the challenge says IP address has been spoofed, then you should look for MAC address as it wouldn’t have changed. You would find packets with two different IP address having same MAC address. In another scenario, if the MAC address has been spoofed, IP address might be the same. In both cases display filter “arp” (to only show arp requests) and “ip.addr==” (to show only packets with either source or destination being the IP address). might be helpful.</li>
<li>Sometimes, it is better to check which objects we are able to export, (File –> Export Objects –> HTTP/DICOM/SMB/SMB2) export the http/DICOM/SMB/SMB2 object</li>
<li>Sometimes, you need to find all the unique ip address in the network capture, for that you can use</li>
</ul>
<blockquote>
<div><div class="highlight-bash"><div class="highlight"><pre><span></span>tshark -T fields -e ip.src -r <pcap file> <span class="se">\|</span> sort <span class="se">\|</span> uniq
-T fields<span class="se">\|</span>pdml<span class="se">\|</span>ps<span class="se">\|</span>psml<span class="se">\|</span>text : Set the format of the output when viewing decoded packet data.
-e : Add a field to the list of fields to display <span class="k">if</span> -T fields is selected.
-r : Read packet data from infile, can be any supported capture file format <span class="o">(</span>including gzipped files<span class="o">)</span>.
-R : Cause the specified filter <span class="o">(</span>which uses the syntax of read/displayfilters, rather than that of capture filters<span class="o">)</span> to be applied
</pre></div>
</div>
</div></blockquote>
<ul class="simple">
<li>Wireshark can not reassamble HTTP fragmented packets to generate the RAW data,we can use Dshell to reassemble http partial contents. A blog mentioning how to do it is <a class="reference external" href="https://github.com/naijim/blog/blob/master/writeups/asis-quals-ctf-2015_broken_heart_writeup.md">here</a>.</li>
</ul>
</div></blockquote>
<ul class="simple">
<li>If in a challenge, you are provided a setgid program which is able to read a certain extension files and flag is present in some other extension, create a symbolic link to the flag with the extension which can be read by the program. For example: In picoCTF 2014 Supercow challenge, a program named supercow was able to read files with .cow extension only and flag was present with flag.txt. So we created a symbolic link like ln -s flag.txt flag.cow</li>
<li>If in a challenge, you are provided with a <strong>APK</strong> file. There are three ways to decompile it as described below:</li>
</ul>
<blockquote>
<div><ul class="simple">
<li>Apktool: It is used to decode resources to nearly original form (including resources.arsc, XMLs and 9.png files) and rebuilding them. Also, used for smali debugging. apktool converts the apk file in to smali format. smali/baksmali is an assembler/disassembler for the dex format used by dalvik, Android’s Java VM implementation.</li>
</ul>
<blockquote>
<div><div class="highlight-bash"><div class="highlight"><pre><span></span>apktool d file.apk output-dir
d : decode to output-dir
</pre></div>
</div>
</div></blockquote>
<ul class="simple">
<li>Dex2jar: To see the java code (approx)</li>
</ul>
<blockquote>
<div><ul class="simple">
<li>Change the extension of file.apk from .apk to .zip</li>
<li>Unzip the file.zip</li>
<li>After unzip, you would get classes.dex file.</li>
<li>Use dex2jar classes.dex (It would create classes_dex2jar.jar file)</li>
<li>Extract jar file by jar xf classes_dex2jar.jar</li>
<li>This would provide you with .class files which could be open by jd-gui (Java Decompiler) tool.</li>
</ul>
</div></blockquote>
<ul class="simple">
<li>Use online services such as Decompile Android. Once it’s decompiled, we can download the decompiled files and unpack them.</li>
</ul>
</div></blockquote>
<ul class="simple">
<li>If you are provided a disk.img file, from which files have to recovered, you could use foremost tool used to recover files using their headers, footers, and data structures.</li>
<li>If you are having a source code of evil program, check the source code of the real program, do a comparision and find the added evil code.</li>
<li>If you are looking for hidden flag in an image first check with file, exiftool command, and make sure the extension is correctly displayed. After that check the image file with hexdump -C and look for interesting pattern may be? If you get 7z or PK they represent Zipped files. If so, you can extract those file with 7z x . If somehow, you get a passphrase for the image, then you might have to use steghide tool as it allows to hide data with a passphrase.</li>
<li>Sometimes, if you extract some files, if you wuld see a blank name, you know there is some file but can’t see a name, like file name could be spaces?, then</li>
</ul>
<blockquote>
<div><div class="highlight-bash"><div class="highlight"><pre><span></span>ls -lb might be of help.
-b, --escape : print C-style escapes <span class="k">for</span> nongraphic characters
</pre></div>
</div>
</div></blockquote>
<ul class="simple">
<li>How to open a filename named “-” : We can create a file named “-” by</li>
</ul>
<blockquote>
<div><div class="highlight-bash"><div class="highlight"><pre><span></span><span class="nb">echo</span> hello > -
</pre></div>
</div>
<p>and this file can be opened by</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>cat ./-
</pre></div>
</div>
<p>This is needed because lot of programs use “-” to mean stdin/stdout.</p>
</div></blockquote>
<ul class="simple">
<li>If you have a hex dump of something and you want to create the binary version of the data?</li>
</ul>
<blockquote>
<div><div class="highlight-bash"><div class="highlight"><pre><span></span>xxd r data
data is the hexdump of the binary file.
</pre></div>
</div>
</div></blockquote>
<ul class="simple">
<li>Excel Document: You may try unzipping it and check VBA macros in it. There are tools to extract VBA from excel listed here ools to extract VBA Macro source code from MS Office Documents</li>
<li>Correct Headers: SQLite3</li>
</ul>
<blockquote>
<div><div class="highlight-default"><div class="highlight"><pre><span></span><span class="mi">0000000</span><span class="p">:</span> <span class="mi">5351</span> <span class="mi">4</span><span class="n">c69</span> <span class="mi">7465</span> <span class="mi">2066</span> <span class="mi">6</span><span class="n">f72</span> <span class="mi">6</span><span class="n">d61</span> <span class="mi">7420</span> <span class="mi">3300</span> <span class="n">SQLite</span> <span class="nb">format</span> <span class="mf">3.</span>
<span class="mi">0000010</span><span class="p">:</span> <span class="mi">0400</span> <span class="mi">0101</span> <span class="mi">0040</span> <span class="mi">2020</span> <span class="mi">0000</span> <span class="mi">000</span><span class="n">b</span> <span class="mi">0000</span> <span class="mi">000</span><span class="n">b</span> <span class="o">.....@</span> <span class="o">........</span>
<span class="mi">0000020</span><span class="p">:</span> <span class="mi">0000</span> <span class="mi">0000</span> <span class="mi">0000</span> <span class="mi">0000</span> <span class="mi">0000</span> <span class="mi">0002</span> <span class="mi">0000</span> <span class="mi">0004</span> <span class="o">................</span>
</pre></div>
</div>
</div></blockquote>
<ul class="simple">
<li>GIF to JPG</li>
</ul>
<blockquote>
<div><div class="highlight-bash"><div class="highlight"><pre><span></span>convert animation.gif target.png
</pre></div>
</div>
</div></blockquote>
<ul class="simple">
<li>If the pdf-parser contains</li>
</ul>
<blockquote>
<div><div class="highlight-bash"><div class="highlight"><pre><span></span>/ProcSet <span class="o">[</span>/PDF/Text/ImageC/ImageI<span class="o">]</span>
/ProcSet <span class="o">[</span>/PDF/Text/ImageC/ImageI<span class="o">]</span>
</pre></div>
</div>
<p>It means it will contain text which can be extracted by using</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>*pdf2txt Untitled-1_1a110935ec70b63ad09fec68c89dfacb.pdf
PCTF<span class="o">{</span>how_2_pdf_yo<span class="o">}</span>*
</pre></div>
</div>
</div></blockquote>
</div>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="LFCCryptography.html" title="Learning from the CTF : Cryptography"
>next</a></li>
<li class="right" >
<a href="LFCBinaryExploitation.html" title="Learning from the CTF : Binary Exploitation"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">tech.bitvijays.com</a> »</li>
</ul>
</div>
<div class="footer" role="contentinfo">
© Copyright 2017, Vijay Kumar.
</div>
</body>
</html>