Monday, September 29, 2008

More Xming Differences


Now that we have seen how to forward X applications over to Windows from Linux, let's look little bit further into Xming.

Keep in mind the 2 main differences when using Xming:

When using 'multiwindow' (I.E Multiple windows option in xlaunch) programs will appear as if they are Window programs. What's great is that you can copy/paste between both!
I've also noted that the performance is really quick and responsive for apps like Firefox. The downside here, of coure, is that you don't not have a "full" X environment.




(Make sure you save your config file regardless of which option you choose to launch your saved session easily.)

For the other options you can have a full X desktop and start up KDE or other window managers. The downside here is that you can not easily copy and paste to your other Windows (non-Linux) applications as neither really know about each other.

Also keep in mind this method will be slower than being at the console (a few seconds' delay in my experince at times for certain window managers), so keep your PCs as close together as possible net-work wise and don't run too many other competing applications, and consider using a faster, lighter-weight window manager like xfce.

Here's a screenshot of a full X environment (kubuntu) that's running in full desktop mode. (NOTE: I actually grabbed a screenshot from my Windows workstation).



Cool, huh?

Friday, September 26, 2008

Get Linux on Windows: Xming X server


I love linux, but I must use a windows PC and don't use multiple monitors.

So lets use an X server to run the application on the linux server and view it on my Windows XP PC.

Enter Xming X Server.

Per the website:

Xming is the leading free unlimited X Window server for Microsoft Windows (XP/2003/Vista). It is fully featured, small and fast, simple to install and being standalone native Microsoft Windows, easily transported portable as a Pocket PC X server.


It took me about 45 seconds to reap the benefits of this product. Easy install and as long as you set "Enable X11 forwarding" in Putty (I.E you don't need to set $DISPLAY), it's easy as

#Whatever-X-program-you-like &

and boom, your PC is hosting the app.




More Info:
http://sourceforge.net/projects/xming

Thursday, September 25, 2008

Wget, W3m, and Curl show headers too!



Since we've talked about Lynx as command line replacement for Liveheaders let's talk about how to use some other command line web browsers to do the same thing. We've seen curl, lynx, and w3m, let's also introduce wget here.


Lynx and w3m are interactive command line web browsers, where curl and wget are more non-interactive web utilities suitable for scripting versus browsing the web.

They all can show the headers they use though. Here's how for each:


WGET:

#wget -q -S -d http://www.google.com -O logfile 2> headers.txt

-q is for quiet mode and -S shows server response while -d shows client commands.

This is all dumped in the headers.txt file.


CURL:

#curl -s http://www.google.com/ -o logfile --trace-ascii tracefile.txt -D headers.txt

-s is for quiet mode and --trace-ascii sends the client and server response to tracefile.txt (it's verbose) and the server response will be sent to headers.txt (it's much cleaner to view than tracefile.txt)


W3M:

#w3m google.com -dump_head > headers.txt

-dump_head sends the server response to headers.txt

(I don't see an option to log what the client sends in the man page), of course we can use curl to help us with that if we really wanted to see it.

Tuesday, September 23, 2008

w3m: Command Line Browser


Per the w3m website: w3m is a pager and/or text-based browser. It can handle table, cookies, authentication, and almost everything except JavaScript.

I found that w3m is great for browsing on the command line and seems to really get close to the GUI experience.

What's really cool is that as you connect to a site w3m will tell you what cookies it's processing.

It's pretty awesome, I was able to login to my forums site http://www.tek-tips.com easily enough, and it seems to get HTML table formatting right too. It also makes good use of screen real estate, which lynx isn't as strong at, though lynx seem more intuitive as far as navigation is concerned.

As for speed lynx was much faster as we mentioned since by default w3m processes every cookie and displays them in the console.

(NOTE: This seems to be resolved in version 0.5.2-1.

See the pics here (lynx takes 4 pages and w3m takes 2 pages to display):

Lynx:



W3m:



More Info:
http://w3m.sourceforge.net/

Monday, September 22, 2008

Lynx as command line replacement for Liveheaders


Liveheaders is great to trace HTTP traffic from a GUI browser.

Here's how to use Lynx as command line replacement for Liveheaders:

Use -trace:

Warning: It's verbose!

The lynx log is started when Lynx trace mode is turned on via the -trace command (default file is Lynx.trace)

I.E

#lynx -accept_all_cookies -trace http://www.google.com

Here's the HTTP Commands Sent by Lynx (in red) and the Header Sent back by a web site (Google.com) (in yellow/red):



Notice the the headers sent back by the web site aren't contiguous, but there's alot of HTML/HTTP diagnostic info.

Also: the "-accept_all_cookies" option will accept all cookies and not prompt you incessantly to accept them.


More Info:
http://lynx.isc.org/
lynx man page

Friday, September 19, 2008

Netcat: Playing with Network Sockets


Another great command-line tool starting with N!

Netcat is a great tool to interact with network services (it's just like telnet but has more options).

The official website says "Netcat is a featured networking utility which reads and writes data across network connections, using the TCP/IP protocol"

What I really like about netcat is the ability to act like a network server and listen on a port.

This is useful to learn how a network client behaves.

For example, here's netcat listening on port 87 of my localhost on the top screen and wget connecting to my localhost on port 87 in the bottom screen.


Here we can see the HTTP commands sent by Wget (I've boxed out the commands in red):



Notice wget identifies itself as Wget/1.10.2. Also notice that the first error is Read Error, since we didn't interact with wget like a web server would and provide a response, we just let it send a command and ignore it.

The second error is Connection Refused since netcat stopped listening to the port afer the first connect by wget, since a connection was made and then closed.

How cool is that?


More info:
http://netcat.sourceforge.net/

Thursday, September 18, 2008

Nmap: Network Scanning!


Nmap has been the Internet's favorite port scanner. It's also a great learning tool to investigate on a private network, or learn about various TCP options and how IP networks work. It's fast too! The Author, Fyodor has a book coming out soon too!

The Author clearly has a sense of humor, here's my attempt as a non-root user trying to do a XMAS tree scan (URG,PSH,and FIN TCP options set in the header):



Here's a screen shot of the capture clearly showing that these 3 flags are set:



(I've circled the 0's and 1's that are supposed to look like XMAS tree bulbs blinking)


You can also use a cool GUI (shocking I know) called zenmap , but it'll help you learn more about the command line options of nmap.


More Info:
http://nmap.org/book/
http://nmap.org/
http://www.networkuptime.com/nmap/page3-5.shtml
http://www.freesoft.org/CIE/Course/Section4/8.htm

Wednesday, September 17, 2008

Ngrep: Sort through your Network Traffic


Tcpdump is great to capture traffic on your network, but sometimes you'd like to have something a little lighter to quickly test network activity (or just spy on your friends).

Ngrep is a pcap-aware tool that will allow you to specify extended regular expressions to match against data part of packets on the network.

That's what the website says.

But more than that it's a lot of fun to play with!

Here's a screen shot of me emailing the word 'Password:' to myself on one terminal and ngrepping and detecting that string on another terminal! (You can find out about alot of things on a network this way)

Super Cool!




More Info:
http://ngrep.sourceforge.net/

Monday, September 15, 2008

Command Line SSH Client for XP

SSH comes standard for any Linux Distribution, but it has been challenging to find a command line SSH client that is not Putty and is not from the cygwin distribution for Windows (XP). That is to say, I just want to fire up a command window prompt and use ssh with the same options as on linux. Well, I found free ssh client which is part of cwRsync. Just unzip it and put it into a directory and for good measure make sure that that path is in your environment path like so:


Right-click on my computer, go to Advanced ->Environment Variables -> System variables -> Path



Now you can do ssh from the command line on XP as easily as Linux.

More Info/Download:
http://www.rsync.net/resources/howto/windows_rsync.html
http://freessh.org/ also has a great list of free and pay ssh clients.

Sunday, September 14, 2008

Using SSH as a Socks Proxy (dynamic application-level port forwarding).


Now that you know how to have FireFox do DNS lookups instead of your PC when using a Socks Proxy, let's show you how to setup a Socks Proxy with SSH.

First some background with what the man page for ssh states for dynamic application-level port forwarding (the -D option):

"Whenever a connection is made to this port, the connection is forwarded over the secure channel, and the application protocol is then used to determine where to connect to from the remote machine. Currently the SOCKS4 and SOCKS5 protocols are supported, and ssh will act as a SOCKS server."


#ssh -D port -g remoteserver

I.E

#ssh -D 15200 -g www.commandlineisking.com

That's it, now your workstation will listen on port 15200. The -g makes the service available over the network for other clients not just the loopback adapter.

To do the same with a putty client:




Now point your browser to the Socks Server 'localhost' like so:



Also note that if you used the -g option, your may also point a different workstation to your workstation and "share" the proxy.

Friday, September 12, 2008

FireFox - Have your Socks proxy do DNS lookups instead of your PC

There is an option in FireFox called network.proxy.socks_remote_dns that will determine whether DNS lookups are to be done on the SOCKS proxy server or client.

In FireFox go to about:config and double click to turn this option on (TRUE) or off (FALSE).




More Info:
https://calomel.org/firefox_ssh_proxy.html
http://kb.mozillazine.org/Network.proxy.socks_remote_dns

Thursday, September 11, 2008

Tuesday, September 9, 2008

Use "Send to" Option for transferring files from XP to Linux with WinSCP



If you work using a Linux machine and XP like I do and need to transfer files often, use the "Send to" Option for transferring files from the Windows Explorer menu to Linux easily.


At the Login dialog, hit the "use Shell icon" button:




and say yes to the prompts after you select "Explorer's Send to Shortcut".



To make this seamless: Make sure your password is saved in WinScp.

To make this seamless and more secure: Use public keys for SSH authentication ( puttygen is a great tool) and do away with passwords.


More Information:
http://winscp.net/eng/docs/integration
http://www.chiark.greenend.org.uk/~sgtatham/putty/

Friday, September 5, 2008

Get All Your Email for Multiple Domains and Users in One Location Easily

You can get all of your email for multiple domains and users in one location easily using Google Apps.


After you set up your Google Apps, the 2 things that make this work are:

-Creating a catch-all address so that all mail to all users go to one mailbox.
-Creating a domain name alias (I.E domainA mail goes to domainB)

Note: Nicknames work really well although the Google doc below indicates they are not included.



More Info:

Domain aliases
http://www.google.com/support/a/bin/answer.py?hl=en&answer=53295

Creating catch-all addresses
http://www.google.com/support/a/bin/answer.py?hl=en-nz&answer=33962

Thursday, September 4, 2008

Control Your Unix Box from your Cell Phone

Your mileage may vary but this is still fun to play with:
http://www.ouellations.com/cellmate/

Cellmate extends the reach of a system administrator by enabling them to control a unix machine using a cell phone. The cell phone simply needs to be able to send a text message a standard SMTP internet address.

Here's the flow of cellmate:

Tuesday, September 2, 2008

Grab your due date from your Credit Card Website

I was curious to have a look under the covers to see exactly how difficult it would be to script a login to my credit card company and grab the due date.


First of all I went to my credit card website. I used Firefox live headers to see the HTTP transactions that take place between the web browser and Web server.


From here you can see the exact post operation after I clicked "Submit" and put in my username and password:




I used Curl, since as I found out, it can follow HTTP 302 redirects (-l option) and send back the cookies the web server sends your browser (-b), and send a post operation (-d option), and of course capture it's output (-o option).


So my command line becomes:


POSTDATA="username=MYUSERNAME&password=MYPASSWORD&Submit=GO&pageid=&acid="
curl -d $POSTDATA -L -b myfile URL_OF_SECURED_SITE -o LOGFILE

With that command, curl just logged in and downloaded my start page, which contains the due date.


From here all need to do is "Screen Scrape" the Due Date from the Page Curl Just Received :


echo "Due Date"
grep 'due' LOGFILE | egrep -io [01][0-9]/[0-3][0-9]/2008


NOTE: Please keep in mind the -b option intentiond is to read a file and send the cookies contained inside. It needs a file specified or else it will raise an error. In my case I didn't have any cookies to read so in essence I was "faking out curl" by simply only turning on its cookie parser but not actually sending cookies from my specified file. I was simply sending the cookies that have been already been set by the Web server.