Thursday, January 18, 2024

Linux Command Line Hackery Series - Part 3


Welcome back, hope you are enjoying this series, I don't know about you but I'm enjoying it a lot. This is part 3 of the series and in this article we're going to learn some new commands. Let's get started

Command: w
Syntax:      w
Function:   This simple function is used to see who is currently logged in and what they are doing, that is, their processes.

Command:  whoami
Syntax:       whoami
Function: This is another simple command which is used to print  the  user  name  associated  with the current effective user ID.

Try it and it will show up your user name.

If you want to know information about a particular user no matter whether it is you or someone else there is a command for doing that as well.

Command: finger
Syntax:      finger [option] [username]
Function:   finger is a user information lookup program. The [] around the arguments means that these arguments are optional this convention is used everywhere in this whole series.

In order to find information about your current user you can simply type:

finger username

Here username is your current username.
To find information about root you can type:

finger root

and it will display info about root user.

Command: uname
Syntax:      uname [options]
Function:   uname is used to display information about the system.

uname is mostly used with the flag -a, which means display all information like this:

uname -a

Command: df
Syntax:      df [option] [FILE ...] 
Function:   df is used to display the amount of space available.
If you type df in your terminal and then hit enter you'll see the used and available space of every drive currently mounted on the system. However the information is displayed in block-size, which is not so much human friendly. But don't worry we can have a human friendly output as well using df by typing:

df -h

the -h flag is used to display the used and available space in a more user friendly format.
We can also view the info of a single drive by specifying the drive name after df like this:

df -h /dev/sda2

That's it for now about df, let's move on.

Command:  free
Syntax:       free [options]
Function:    free is used to display the amount of free and used physical memory and swap memory in the system.
Again the displayed information is in block-size to get a more human readable format use the -h flag like this:

free -h

Command: cal
Syntax:      cal [options]
Function:    cal stands for calendar. It is used to display the calendar.

If you want to display current date on the calendar you can simply type:

cal

and wohooo! you get a nice looking calendar on screen with current date marked but what if you want to display calendar of a previous month well you can do that as well. Say you want to display calendar of Jan 2010, then you'll have to type:

cal -d 2010-01

Nice little handy tool, isn't it?

Command: file
Syntax:      file filename ...
Function:   file is an awesome tool, it's used to classify a file. It is used to determine the file type.

Let's demonstrate the usage of this command by solving a Noob's CTF challenge using file and base64 commands. We'll talk about base64 command in a bit. Go to InfoSecInstitute CTF Website. What you need to do here is to save the broken image file on your local computer in your home directory. After saving the file open your terminal (if it isn't already). Move to your home directory and then check what type of file it is using the file command:

cd
file image.jpg

Shocking output? The file command has identified the above file as an ASCII text file which means the above file is not an image file rather it is a text file now it's time to see it's contents so we'll type:

cat image.jpg

What is that? It's some kind of gibberish. Well it's base64 encoded text. We need to decode it. Let's learn how to do that.

Command: base64
Syntax:       base64 [option] FILE ...
Function:    base64 command is used to encode/decode data and then print it to stdout.

If we're to encode some text in base64 format we'd simply type base64 hit enter and then start typing the text in the terminal after you're done hit enter again and then press CTRL+D like this:

base64
some text here
<CTRL+D>
c29tZSB0ZXh0IGhlcmUK        # output - the encoded string

But in the above CTF we've got base64 encoded data we need to decode it, how are we going to do that? It's simple:

base64 -d image.jpg

There you go you've captured the flag.
The -d flag here specifies that we want to decode instead of encode and after it is the name of file we want to decode.

Voila!
So now you're officially a Hacker! Sorry no certificates available here :)

That's it for this article meet ya soon in the upcoming article.
Related posts
  1. Pentest Tools
  2. Install Pentest Tools Ubuntu
  3. Hacker Search Tools
  4. Install Pentest Tools Ubuntu
  5. Pentest Tools Tcp Port Scanner
  6. Hack Tools For Ubuntu
  7. Hacking Tools Windows
  8. Hacker Tools Mac
  9. Hacking Tools For Mac
  10. Hacker
  11. Hack Tools 2019
  12. Hacking Tools Pc
  13. Hack Tools 2019
  14. Hacker Hardware Tools
  15. Pentest Tools List
  16. Termux Hacking Tools 2019
  17. Hack Tools Online
  18. Hacking Tools 2019
  19. Top Pentest Tools
  20. Hacker Tools For Ios
  21. Hacking Tools Usb
  22. Pentest Tools Kali Linux
  23. Top Pentest Tools
  24. Growth Hacker Tools
  25. Hack Tools
  26. Hacker Tools Linux
  27. Hacker Tools Free
  28. Hacker Tools Github
  29. Pentest Tools Bluekeep
  30. Pentest Tools Kali Linux
  31. Wifi Hacker Tools For Windows
  32. Nsa Hacker Tools
  33. Hack And Tools
  34. Pentest Tools Find Subdomains
  35. Hack Website Online Tool
  36. New Hack Tools
  37. Termux Hacking Tools 2019
  38. Hacker Tools
  39. How To Install Pentest Tools In Ubuntu
  40. Pentest Automation Tools
  41. Pentest Tools Alternative
  42. Pentest Tools Website
  43. Pentest Tools Website Vulnerability
  44. Hack Tools Pc
  45. Hack Rom Tools
  46. Hacking Tools For Windows
  47. Hack Tools Mac
  48. Hack App
  49. Github Hacking Tools
  50. New Hacker Tools
  51. Tools 4 Hack
  52. Android Hack Tools Github
  53. Pentest Tools Tcp Port Scanner
  54. Github Hacking Tools
  55. Hacking Tools For Windows Free Download
  56. Hacking Tools Name
  57. Hacking Tools For Games
  58. Pentest Tools Framework
  59. Usb Pentest Tools
  60. Hackrf Tools
  61. Hacker Tools
  62. Hacker Tools Apk
  63. Pentest Tools For Mac
  64. Hacking Tools Pc
  65. Pentest Tools Apk
  66. Hacker Tools Mac
  67. How To Install Pentest Tools In Ubuntu
  68. Hacker Tools 2020
  69. What Are Hacking Tools
  70. Hacking Tools Github
  71. Pentest Tools Port Scanner
  72. Black Hat Hacker Tools
  73. How To Install Pentest Tools In Ubuntu
  74. Physical Pentest Tools
  75. Pentest Tools Find Subdomains
  76. Hacking Tools Hardware
  77. Beginner Hacker Tools
  78. Pentest Tools Find Subdomains
  79. Easy Hack Tools
  80. Nsa Hack Tools
  81. Hacker Tool Kit
  82. Ethical Hacker Tools
  83. Free Pentest Tools For Windows
  84. Hacker
  85. Pentest Automation Tools
  86. Hacker Tools For Ios
  87. Pentest Tools Port Scanner
  88. Hack App
  89. Pentest Tools Tcp Port Scanner
  90. Hackrf Tools
  91. Pentest Box Tools Download
  92. Hacking Tools For Windows 7
  93. Top Pentest Tools
  94. Pentest Tools For Windows
  95. Hack Apps
  96. Pentest Tools Download
  97. Hacker Tool Kit
  98. Termux Hacking Tools 2019
  99. Easy Hack Tools
  100. World No 1 Hacker Software
  101. Nsa Hack Tools Download
  102. Pentest Tools Apk
  103. How To Install Pentest Tools In Ubuntu
  104. Pentest Reporting Tools
  105. Pentest Tools Github
  106. Hacking Tools Free Download
  107. Pentest Tools Subdomain
  108. Game Hacking
  109. Hacker Tools
  110. Computer Hacker

Learning Web Pentesting With DVWA Part 2: SQL Injection

In the last article Learning Web Pentesting With DVWA Part 1: Installation, you were given a glimpse of SQL injection when we installed the DVWA app. In this article we will explain what we did at the end of that article and much more.
Lets start by defining what SQL injection is, OWASP defines it as: "A SQL injection attack consists of insertion or "injection" of a SQL query via the input data from the client to the application. A successful SQL injection exploit can read sensitive data from the database, modify database data (Insert/Update/Delete), execute administration operations on the database (such as shutdown the DBMS), recover the content of a given file present on the DBMS file system and in some cases issue commands to the operating system. SQL injection attacks are a type of injection attack, in which SQL commands are injected into data-plane input in order to effect the execution of predefined SQL commands."
Which basically means that we can use a simple (vulnerable) input field in our web application to get information from the database of the server which hosts the web application. We can command and control (at certain times) the database of the web application or even the server.
In this article we are going to perform SQL injection attack on DVWA, so let's jump in. On the DVWA welcome page click on SQL Injection navigation link. We are presented with a page with an input field for User ID.
Now lets try to input a value like 1 in the input field. We can see a response from server telling us the firstname and surname of the user associated with User ID 1.
If we try to enter a user id which doesn't exist, we get no data back from the server. To determine whether an input field is vulnerable to SQL injection, we first start by sending a single quote (') as input. Which returns an SQL error.
We saw this in the previous article and we also talked about injection point in it. Before diving deeper into how this vulnerability can be exploited lets try to understand how this error might have occurred. Lets try to build the SQL query that the server might be trying to execute. Say the query looks something like this:
SELECT first_name, sur_name FROM users WHERE user_id = '1';
The 1 in this query is the value supplied by the user in the User ID input field. When we input a single quote in the User ID input field, the query looks like this:
SELECT first_name, sur_name FROM users WHERE user_id = '''; 
The quotes around the input provided in the User ID input field are from the server side application code. The error is due to the extra single quote present in the query. Now if we specify a comment after the single quote like this:
'-- -
or
'#
we should get no error. Now our crafted query looks like this:
SELECT first_name, sur_name FROM users WHERE user_id = ''-- -'; 
or
SELECT first_name, sur_name FROM users WHERE user_id = ''#'; 
since everything after the # or -- - are commented out, the query will ignore the extra single quote added by the server side app and whatever comes after it and will not generate any error. However the query returns nothing because we specified nothing ('') as the user_id.
After knowing how things might be working on the server side, we will start to attack the application.
First of all we will try to determine the number of columns that the query outputs because if we try a query which will output the number of columns greater or smaller than what the original query outputs then our query is going to get an error. So we will first figure out the exact number of columns that the query outputs and we will do that with the help of order by sql statement like this:
' order by 1-- - 
This MySQL server might execute the query as:
SELECT first_name, sur_name FROM users WHERE user_id = '' order by 1-- -'; 
you get the idea now.
if we don't get any error message, we will increase the number to 2 like this:
' order by 2-- - 
still no error message, lets add another:
' order by 3-- - 
and there we go we have an error message. Which tells us the number of columns that the server query selects is 2 because it erred out at 3.
Now lets use the union select SQL statement to get information about the database itself.
' union select null, version()-- - 
You should first understand what a union select statement does and only then can you understand what we are doing here. You can read about it here.
We have used null as one column since we need to match the number of columns from the server query which is two. null will act as a dummy column here which will give no output and the second column which in our case here is the version() command will output the database version. Notice the output from the application, nothing is shown for First name since we specified null for it and the maria db version will be displayed in Surname.
Now lets check who the database user is using the user() function of mariadb:
' union select null, user()-- - 
After clicking the submit button you should be able to see the user of the database in surname.

Now lets get some information about the databases in the database.
Lets determine the names of databases from INFORMATION_SCHEMA.SCHEMATA by entering following input in the User ID field:
' union select null, SCHEMA_NAME from INFORMATION_SCHEMA.SCHEMATA-- - 
This lists two databases dvwa and information_schema. information_schema is the built in database. Lets look at the dvwa database.
Get table names for dvwa database from INFORMATION_SCHEMA.TABLES
' union select null, TABLE_NAME from INFORMATION_SCHEMA.TABLES-- - 
It gives a huge number of tables that are present in dvwa database. But what we are really interested in is the users table as it is most likely to contain user passwords. But first we need to determine columns of that table and we will do that by querying INFORMATION_SCHEMA.COLUMNS like this:
' union select null, COLUMN_NAME from INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'users'-- - 

We can see the password column in the output now lets get those passwords:
' union select user, password from users-- - 
Of-course those are the hashes and not plain text passwords. You need to crack them.
Hope you learned something about SQL injection in this article. See you next time.

References:

1. SQL Injection: https://owasp.org/www-community/attacks/SQL_Injection
2. MySQL UNION: https://www.mysqltutorial.org/sql-union-mysql.aspx
3. Chapter 25 INFORMATION_SCHEMA Tables: https://dev.mysql.com/doc/refman/8.0/en/information-schema.html
Continue reading

Wednesday, January 17, 2024

Steghide - A Beginners Tutorial




All of us want our sensitive information to be hidden from people and for that we perform different kinds of things like hide those files or lock them using different softwares. But even though we do that, those files  attractive people to itself as an object of security. Today I'm going to give you a slight introduction to what is called as Steganography. Its a practice of hiding an informational file within another file like you might have seen in movies an image has a secret message encoded in it. You can read more about Steganography from Wikipedia.


In this tutorial I'm going to use a tool called steghide, which is a simple to use Steganography tool and I'm running it on my Arch Linux. What I'm going to do is simply encode an image with a text file which contains some kind of information which I don't want other people to see. And at the end I'll show you how to decode that information back. So lets get started:


Requirements:

1. steghide
2. a text file
3. an image file

After you have installed steghide, fire up the terminal and type steghide




It will give you list of options that are available.


Now say I have a file with the name of myblogpassword.txt which contains the login password of my blog and I want to encode that file into an Image file with the name of arch.jpg so that I can hide my sensitive information from the preying eyes of my friends. In order to do that I'll type the following command in my terminal:


steghide embed -ef myblogpassword.txt -cf arch.jpg




here steghide is the name of the program

embed flag is used to specify to steghide that we want to embed one file into another file
-ef option is used to specify to steghide the name (and location, in case if its in some other directory) of the file that we want to embed inside of the another file, in our case its myblogpassword.txt
-cf option is used to specify the name (and location, in case if its in some other directory) of the file in which we want to embed our file, in our case its an image file named arch.jpg

After typing the above command and hitting enter it will prompt for a password. We can specify a password here in order to password protect our file so that when anyone tries to extract our embedded file, they'll have to supply a password in order to extract it. If you don't want to password protect it you can just simply hit enter.


Now myblogpassword.txt file is embedded inside of the image file arch.jpg. You'll see no changes in the image file except for its size. Now we can delete the plain password text file myblogpassword.txt.


In order to extract the embedded file from the cover file, I'll type following command in the terminal:


steghide extract -sf arch.jpg -xf myblogpass.txt




here steghide is again name of the program
extract flag specifies that we want to extract an embedded file from a stego file
-sf option specifies the name of the stego file or in other words the file in which we embedded another file, in our case here its the arch.jpg file
-xf option specifies the name of the file to which we want to write our embedded file, here it is myblogpass.txt
(remember you must specify the name of file with its location if its somewhere else than the current directory)

After typing the above command and hitting enter, it will prompt for a password. Supply the password if any or otherwise just simply hit enter. It will extract the embedded file to the file named myblogpass.txt. Voila! you got your file back but yes the image file still contains the embedded file.


That's it, very easy isn't it?


It was a pretty basic introduction you can look for other things like encrypting the file to be embedded before you embed it into another file and so on... enjoy
:)

More articles


  1. Pentest Recon Tools
  2. Termux Hacking Tools 2019
  3. Hacking Tools For Games
  4. Pentest Tools Bluekeep
  5. Hacker Tools Online
  6. Hacker Tools Windows
  7. Hacker Tools List
  8. Hacker Tools
  9. Underground Hacker Sites
  10. Hacking Tools For Windows
  11. Hackrf Tools
  12. Hackrf Tools
  13. Hacker Tools Github
  14. Kik Hack Tools
  15. Termux Hacking Tools 2019
  16. Hack Apps
  17. Hack Tools Github
  18. Hacking Tools
  19. Best Hacking Tools 2020
  20. Top Pentest Tools
  21. Pentest Tools Subdomain
  22. Pentest Tools Free
  23. Hack App
  24. Hacker Tools Github
  25. Nsa Hacker Tools
  26. Hacker Security Tools
  27. Beginner Hacker Tools
  28. Pentest Tools Subdomain
  29. Hack Tool Apk
  30. Hacking Tools Free Download
  31. Hack Tools Pc
  32. Hacker Tools Hardware
  33. Nsa Hack Tools Download
  34. Hacking Tools Online
  35. Hacking Tools
  36. Hack Tool Apk No Root
  37. Hacking Tools Download
  38. Hacking Tools For Windows Free Download
  39. Pentest Tools Find Subdomains
  40. Hack Website Online Tool
  41. Pentest Tools Download
  42. Hack Website Online Tool
  43. Hacker Tools Apk
  44. How To Hack
  45. Hacker Tools Apk Download
  46. Pentest Tools Port Scanner
  47. Pentest Tools Open Source
  48. Hacker Tools Apk Download
  49. Physical Pentest Tools
  50. Hacking Apps
  51. Pentest Tools Bluekeep
  52. Hack Tools Download
  53. Pentest Automation Tools
  54. Hacking Tools For Mac
  55. Black Hat Hacker Tools
  56. Best Hacking Tools 2019
  57. Game Hacking
  58. Pentest Box Tools Download
  59. Hacker Tools List
  60. Hacker Tools Github
  61. Hacking Tools Pc
  62. Pentest Tools Url Fuzzer
  63. Pentest Automation Tools
  64. Hacking Tools Windows 10
  65. Hacking Tools And Software
  66. Black Hat Hacker Tools
  67. Bluetooth Hacking Tools Kali
  68. Pentest Tools Nmap
  69. Hacker Tools Mac
  70. Termux Hacking Tools 2019
  71. What Is Hacking Tools
  72. Pentest Tools Website
  73. Hacker Tools Online
  74. Nsa Hacker Tools
  75. Hacker Tools Linux
  76. Hacking Tools Mac
  77. Hacking Tools Download
  78. Pentest Tools Kali Linux
  79. Hacker Tools List
  80. Pentest Tools Windows
  81. Hack Tools For Pc
  82. Hacker Tools 2020
  83. Pentest Tools Github
  84. Hacking Tools For Pc
  85. Hacker Search Tools
  86. Hack Tools
  87. Hacker Tools 2019
  88. Hacking Tools Software
  89. Hack Tools For Windows
  90. Nsa Hack Tools Download
  91. Easy Hack Tools
  92. Hack Website Online Tool
  93. Pentest Tools Subdomain
  94. Hack Tools For Games
  95. Pentest Tools For Ubuntu
  96. Pentest Tools Alternative
  97. What Is Hacking Tools
  98. Pentest Tools Linux
  99. Hacking Tools For Kali Linux
  100. Hacker Tools Free Download
  101. Termux Hacking Tools 2019
  102. Pentest Tools Nmap
  103. Hack Tools Download
  104. Hacker Tools For Windows
  105. Hacks And Tools
  106. Hack Tool Apk
  107. Hacker Tools Apk
  108. Hacking Tools Download
  109. Pentest Tools Nmap
  110. Nsa Hack Tools Download
  111. Hacking Tools
  112. What Is Hacking Tools
  113. Hack Tools For Games