Wednesday, July 9, 2014

Encodings (personal notes)

This is not supposed to be pretty, just for me:

ENCODINGS N' SHIT

From hex to string
print("\x41") #will print "A" since 41 is the hex of capital A
  A

From string to hex
"A".encode("hex")
  41

From hex to string (again)
"41".decode("hex")
  A

  encoder/decode supports hex, base64, utf-8, rot13, and a bunch others (https://docs.python.org/2/library/codecs.html#standard-encodings)

URL encode:
import urllib
urllib.quote_plus("HOLA\":!@$")
  HOLA%22%3A%21%40%24

Wednesday, July 2, 2014

Python script to grab the title of a page

#!/usr/bin/env python
import urllib2
import sys
from BeautifulSoup import BeautifulSoup
#expects "http://example.com" as argument

try:
    urllib2.urlopen(sys.argv[1])
except urllib2.HTTPError, e:
    print sys.argv[1], '--- HTTPERROR'
    quit()


soup = BeautifulSoup(urllib2.urlopen(sys.argv[1]))

if soup.title:
  print sys.argv[1], "--- ", soup.title.string
else:
  print sys.argv[1], '--- NULL'

Thursday, June 19, 2014

Getting Internal IP from WebDAV via PROPFIND method using curl

I wanted a curl line that would grab the disclosed internal IP from a webserver.

It turns out that you need to specify an empty host header, and the content length of 0 for it to work.

If you dont specify the empty host header, it will just spit back the XML with whatever host header you specify. And you need a content length of 0 because the server expects a content length header :/

Below is the curl line to get the IP in the body of the message:

curl -v -k -H "Host:" -H "Host;" -H "Content-Length: 0" -X PROPFIND http://example.com:1234

Friday, February 14, 2014

Cool Bash Trick: Constantly updating a "status" line in bash script

Lots of times i'm dealing with repetitius data and i dont like that it can take up so much of my screen when i'm really only outputting something like "Portion 3 is done" and the only thing that updates is the number.

It's annoying to have a screen full of:
Portion 1 is done
Portion 2 is done
Portion 3 is done
Portion 4 is done
...


I'd like it if only one line is used to tell me the current done portion. Well, it turns out there is a way to do this with bash scripts.

It turns out there is "\r" which means carriage return. So if you output a carriage return WITHOUT a newline then you essentially clear that line of text.

A simple double for loop to visually see what i'm talking about:
for j in $(seq 1 10); do 
  for i in $(seq 1 20); do 
    printf "$i is part of $j \r"
    sleep .1
  done 
done

Monday, December 30, 2013

Ruby script to grab a fake name out of fakenamegenerator.com

require 'open-uri'
require 'nokogiri'

Nokogiri::HTML(open('http://www.fakenamegenerator.com/')).xpath("//div[@class='address']/h3").collect {|node| puts node.text.strip}

Thursday, November 21, 2013

Burn Linux ISO image to USB drive on a Mac OSX

Ubuntu has a guide on doing it for ubuntu installs, but it should work just fine for the other distros:

http://www.ubuntu.com/download/desktop/create-a-usb-stick-on-mac-osx

I tested it with debian and it worked fine.

Tuesday, November 19, 2013

Legal advice for all you evil hackers

What to do in the case of a "knock and talk" by the police:
http://www.primermagazine.com/2013/learn/legally-speaking-police-are-at-the-door

What to do if the police have a search warrant:
http://www.avvo.com/legal-guides/ugc/what-to-do-when-the-police-show-up-at-your-house-with-a-search-warrant

Monday, October 14, 2013

How to check if an IP from a domain is in a list of IPs

grep $(dig +short blah.domain.com) file-of-ips.txt
the +short parameter only returns the IP that the blah.domain.com resolves to.

Friday, October 4, 2013

VX8DR RX/TX Freqs

Stole this from some forum. just google it and you can find the source.

RX
Frequency Note
0.5 - 1.8 MHz BC Band. AM Radio
1.8 - 30 MHz Shortwave Band.
30 - 78 MHz 6 Meter Ham
76 - 108 MHz FM Radio
108 - 137 MHz Air Band
137 - 174 MHz 144 MHz Ham. 2 Meter
174 - 222 MHz VHF-TV
222 - 225 MHz 222 MHz Ham
225 - 420 MHz General Band 1
420 - 470 MHz 440 MHz Ham. 70 cm.
470 - 800 MHz UHF-TV
800 - 999 MHz General Band 2 Cellular Blocked

TX
50 - 54 MHz
144 - 148 MHz
222 - 225 MHz USA version only
430 - 440 MHz

TX w/ mod
50 - 54 MHz
144 - 148 MHz
148 - 174 MHz MARS/CAP Mod only
222 - 225 MHz USA version only
430 - 440 MHz
440 - 470 MHz MARS/CAP Mod only. FRS/GMRS freq range

Tuesday, September 17, 2013

Test allowed firewall ports

Sometimes you are behind some paywall/captive portal/firewall and you feel like certain pors would be left through if only you knew which of the over 65,000 ports did. The only way to really know is to check each one individually. Thats where http://portquiz.net/ comes in.

It's a site that registers every port as open. This way you know that if something is allowed through, it will come back in your port scan.

So behind your firewall, this:
nmap -p- -T4 portquiz.net -oA firewallcheck
now you can check the firewallcheck.nmap (or parse it out of gnmap) and find out which ports allow data through.