Category Archives: linux - Page 2

SourceForge direct download with clean filename

If you ever wget files from source forge you’ll know how the file name will be annoying with a bunch of extra crap

so…:

 

#!/bin/bash
file=`echo $1 | sed 's,.*/,,g; s/?.*//'`
echo $file
wget "$1" -O ./$file

for:

% ~/sf.sh "http://downloads.sourceforge.net/project/gns-3/GNS3/0.8.3.1/GNS3-0.8.3.1-src.tar.bz2?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fgns-3%2F%3Fsource%3Ddirectory&ts=1354547913&use_mirror=voxel"
GNS3-0.8.3.1-src.tar.bz2
--2012-12-03 10:18:49--  http://downloads.sourceforge.net/project/gns-3/GNS3/0.8.3.1/GNS3-0.8.3.1-src.tar.bz2?r=http%3A%2F%
<>

Length: 2611269 (2.5M) [application/x-bzip2]
Saving to: `./GNS3-0.8.3.1-src.tar.bz2'

100%[=======================================================================================================================================================================>] 2,611,269   2.37M/s   in 1.1s    

2012-12-03 10:19:16 (2.37 MB/s) - `./GNS3-0.8.3.1-src.tar.bz2' saved [2611269/2611269]
 
( ~/del/sftest )% ls
GNS3-0.8.3.1-src.tar.bz2

yay!

Bash one liner: rDNS of failed ssh logins

Quickly get the rDNS of each IP that failed to login to your ssh :D

grep Failed /var/log/auth.log|grep -v pronto|sed 's/.*from //;s/ port.*//'|sort -u|while read host
do
        host "$host"
done
Host 196.108.80.114.in-addr.arpa not found: 2(SERVFAIL)
Host 71.102.207.124.in-addr.arpa not found: 2(SERVFAIL)
Host 192.190.210.125.in-addr.arpa. not found: 3(NXDOMAIN)
Host 248.196.211.125.in-addr.arpa. not found: 3(NXDOMAIN)
218.15.28.176.in-addr.arpa domain name pointer lvps176-28-15-218.dedicated.hosteurope.de.
Host 242.15.120.187.in-addr.arpa. not found: 3(NXDOMAIN)
Host 253.109.15.198.in-addr.arpa. not found: 3(NXDOMAIN)
Host 179.115.27.198.in-addr.arpa not found: 2(SERVFAIL)
8.197.61.198.in-addr.arpa domain name pointer 198-61-197-8.static.cloud-ips.com.
Host 159.203.61.198.in-addr.arpa. not found: 3(NXDOMAIN)
Host 60.82.71.198.in-addr.arpa. not found: 3(NXDOMAIN)
178.230.241.201.in-addr.arpa domain name pointer pc-178-230-241-201.cm.vtr.net.
Host 66.2.62.42.in-addr.arpa not found: 2(SERVFAIL)
82.179.79.4.in-addr.arpa domain name pointer scanning-service-4.nessus.org.
Host 61.226.49.64.in-addr.arpa. not found: 3(NXDOMAIN)
38.96.111.78.in-addr.arpa domain name pointer fire3.methosting.com.
7.138.17.85.in-addr.arpa domain name pointer hosted-by.leaseweb.com.
Host 72.129.211.95.in-addr.arpa. not found: 3(NXDOMAIN)

:D    also you can replace the “host “$host”  part with:    whois “$host” > $host    and quickly whois each IP as well, I recommend doing this in it’s own DIR though.  Then just do less *   and :n  to go to next file

Breakdown on the one liner for people new to linux/bash/celery
This part is pretty self explanatory, just greping auth.log for Failed, then grep -v is an inverse grep getting rid of my user name

grep Failed /var/log/auth.log|grep -v pronto

This part using is removing everything up to and including the word ‘from’ then everything and including the word ‘port’
the sed command is acutely doing two sed actions separated via a semicolon (no need to pipe sed to sed)

sed 's/.*from //;s/ port.*//'
the original line looks like:
Nov  9 08:22:56 tasty sshd[25254]: Failed password for root from 199.83.51.16 port 54268 ssh2
 
then end result is just "199.83.51.16"

for more useful sed one liners check out this page
this next part just sorts the massive list, and the -u flag only shows the unique ones

sort -u

 

ssh, socks5 proxy, and windows

I have this VPS that has an ipv6 address (yay! I’m so awesome…)
Sadly my ISP does not yet provide ipv6 (evil FiOS, but that’s a rant on it’s own), so while using linux I’m able to do simple socks5 proxy to be able to use the ipv6 awesomness, eg:

$ ssh -D 50502 remote.server.here

firefox proxy config

Yay, I’m now browsing the web via the socks5 proxy, and when I go to http://test-ipv6.com/ I get a lovely 10/10 and I see my VPS’s ipv6 address

When I try to do this on putty via windows7 ipv6 does NOT work *sadface*

Windows7, firefox, putty, socks5, no ipv6! :(

Evil Javascript and snopes.com

As someone who likes to select text as they read it, snopes.com use of javascript to disable that is rather annoying.

yes I know about noscript/etc… but they shouldn’t be disabling text selection in the first place, it does nothing to protect content

…to prove it, i cloned all of snopes.com and disabled that javascript

eg: (if you have JS enabled) http://www.snopes.com/holidays/christmas/humor/check.asp no text selection, lame!

http://198.27.92.150/snopes.com/holidays/christmas/humor/check.asp yay, can has text selection

full site: http://198.27.92.150/snopes.com/

—-
Stats:

du -sh ./* | grep snopes
144M ./snopes.com
13M ./snopes.js.tar.bz2
 
(text always impresses me how well it compresses)
 
# find snopes.com/|wc -l
6145
 
# find snopes.com/ -name "*.html"| wc -l
5328
 
that means: 6145 total files, 5328 are html pages for the stories

—-

you may find yourself asking “how the hell?”
simple! wget + find + xargs + sed + bored

wget \
--recursive \
--no-clobber \
--page-requisites \
--html-extension \
--convert-links \
--restrict-file-names=windows \
--no-parent \
-D snopes.com \
--limit-rate=500k\
--user=agent="Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:15.0) Gecko/20100101 Firefox/15.0.1" \
<a href="http://snopes.com/" target="_blank">http://snopes.com</a>

then to disabled that javascript

find . -name "*html" -print | xargs sed -i 's/var omitformtags/#var omitformtags/g'

^ what that does is list every file ending in: “.html” and makes it a massive list, kinda like:

# find snopes.com/ -name "*.html"| tail
snopes.com/humor/lists/childsup.asp.html
snopes.com/humor/lists/olympics.asp.html
snopes.com/humor/lists/insurance.asp.html
snopes.com/humor/misxlate/engliz.asp.html

then it passes that list off to xargs, which runs the sed command on each file to comment out “var omitformtags” which in return breaks the JS that disables text selection.

took all of ~20 minutes to grab every file on snopes.com via that, then a few seconds to disable that javascript on 5328 html files

this is not only a lesson in dont annoy linux geeks, but also automation and how to edit 5000+ files in seconds

custom htop theme

you can get it here

htop

htop

Made my own htop theme :D
red ftw.

htop

htop.

..yes, i named the theme “Pronto”