Archive

Archive for the ‘windows’ Category

How to SSH Tunneling in Windows and Linux

November 9th, 2009 sadegh No comments

If you ever wanted to ssh tunnel your traffic here is how to do that on Linux box or Windows box.

On Linux box then just enter the following line :

ssh -fND localhost:3443 ServerUName@Server

You gotta change ServerUName to Username and Server to the IP or the name of server you are logging into.

On Windows Box you need to download putty ( Download ) then Open it up

It doesn’t require any installation just double click on putty.exe after it opened up in the left menu select SSH in the “Preferred SSH protocol version” choose 2 and above it check the “Enable Compression”

Figure 1

Figure 1

Then click the plus sign beside SSH in left menu to expand it, then select “Tunnels” afterward in the right section in “Source port” enter for example 3443 and below the destination choose dynamic as in the below figure. ( Sorry in this figure I entered 9191 instead of 3443 but it doesnt matter you can enter whatever you want but you gotta change all the others 3443 as well if you change it)

Figure 2

Figure 2

Then hit “Add”, Now in forwarded lists you would see “D3443”.

Now scroll up the left menu and choose “Session” in the “Host Name” enter the IP Address or the host name and then click on “Open” button

Figure

Figure

Then it will ask your credential enter them.

Figure 4

Figure 4

So now in Firefox I go to Edit → Preferences → Advanced → Network → Settings → Choose Manual proxy configuration , Uncheck Use this proxy server for all protocols and clean HTTP proxy and its port Field and all the other fields then go to SOCKS Host and enter localhost into that field and in the port field enter 3443.

Figure 5

Figure 5

Then click on ok and close all the window ,

Now all the traffics in Firefox first go to your server and then from that server goes to outside world or to your Computer.

You can confirm that by going to ipchicken.com, You should see the IP Address of the server that you just set for tunneling not your own IP Address.

Automating your tasks , AutoIT

August 19th, 2009 sadegh 1 comment
MsgBox(0, "nothingelz.com", "Hello World!")

The above line is a simple code which shows a Message Box. You just need to open notepad write it down and save it with “.au3” extension, oh I was almost forgetting before that you need to go to http://www.autoitscript.com/autoit3/downloads.shtml and download AutoIt . Unfortunately Windows is only supported operation system.

AutoIt

AutoIt

Well thats it, You created your first AutoIt script.  It’s cool, isn’t it  ? AutoIT is actually really good for small daily work, you can write small script in AutoIt to do your daily chores

e.g. I use following script everyday morning when I arrive at work :

$answer = MsgBox(4, "nothingelz.com", "Good morning , do you want me to start Visual Studio and SQL Server Management Studio and Firefox ?")

If $answer = 7 Then

MsgBox(0, "nothingelz.com", "OK.  c ya!")

Exit

EndIf

Run("C:\Program Files\Mozilla Firefox\firefox.exe") ; firefox huh ?

Run("C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe") ;visual studio

Run("C:\Program Files\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\SqlWb.exe") ;sql …

It will ask me whether or not I want it to run Firefox , Visual Studio and Sql Server Management Studio ( these are application that I use everyday at work ) so I do not need to put all of these apps short cut on my desktop and also with one click all of them will be lunched ;)

So lets analyze Above code , in first line I called MsgBox function and put its returns value to variable called $answer. MsgBox accepts three parameters , the first one is called flag which indicate which kind of Message box we want with which kinda buttons combination

0 OK button
1 OK and Cancel
2 Abort, Retry, and Ignore
3 Yes, No, and Cancel
4 Yes and No
5 Retry and Cancel
6 ** Cancel, Try Again, Continue

This table shows  possible value for flag parameter, as you see we used 4 which means that we want Yes/No MsgBox.

The second parameter is Message Box Title and the third one is its message. This function return a value , possible returned values includes :

Button Pressed Return Value
OK 1
CANCEL 2
ABORT 3
RETRY 4
IGNORE 5
YES 6
NO 7
TRY AGAIN ** 10
CONTINUE ** 11

In  conditional statement ( If statement ) we check whether user clicked on “No” or not ( in the above table you see that if our return value is 7 , it means user clicked on “No”) . if it was correct we move on next line and show a message to user and then we call “Exit” which exit our script otherwise we skip it and go to the whatever comes after “Endif” .

Then we call Run function, it accepts a path to a file and run it. We just call it three times with path to Firefox , Visual Studio and Sql Server Management Studio.

That’s it, You can change parameter of “Run” and point it to the application which you use. Almost everything else in AutoIt is the same as above code.  A Complete Help comes along with AutoIt which contains list of all function and their parameters and return value and purpose of them which is really helpful.

AutoIt is really cool scripting language you can learn it very soon and it has a rich library, full of useful functions.

Categories: programming, windows Tags: ,