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.

Wednesday, August 21, 2013

Number of Potential Ports in Private IP Space

So this is kind of interesting and it might be useful in the future.

The 10/8 network has 16,777,216 addresses

The 172.16/12 network has 1,048,576 addresses

The 192.168/16 network has 65,536 addresses

Combine those with 65,536 port numbers for TCP and the same for UDP and you get over 2.3 trillion (2,345,052,143,616) potential service endpoints.

So next time someone wants you to scan their private IP space, doesnt tell you what ranges there are and expects you to do it in 2 weeks, tell them to politely fuck off.

Thursday, August 15, 2013

echo colored text in bash

Lots of tutorials tell you to use the "echo -e [blahblah" ANSI escape sequences to generate the colors for output. First of all those are practically impossible to read easily, they look like magic, and its a bitch to try to find a typo.

tput was created a while ago to remedy those issues. I've created a function/script that can be included in other scripts to easily generate colors.
#!/bin/bash
echo_color() {
 case ${1} in
 black)
  shift 1
  #echo $(COLOR)${user-supplied-text}$(NORMAL-COLOR)
  echo $(tput setaf 0)${*}$(tput sgr0)
  ;;
 red)
  shift 1
  echo $(tput setaf 1)${*}$(tput sgr0)
  ;;
 green)
  shift 1
  echo $(tput setaf 2)${*}$(tput sgr0)
  ;;
 yellow)
  shift 1
  echo $(tput setaf 3)${*}$(tput sgr0)
  ;;
 blue)
  shift 1
  echo $(tput setaf 1)${*}$(tput sgr0)
  ;;
 cyan)
  shift 1
  echo $(tput setaf 6)${*}$(tput sgr0)
  ;;
 magenta)
  shift 1
  echo $(tput setaf 5)${*}$(tput sgr0)
  ;;
 white)
  shift 1
  echo $(tput setaf 7)${*}$(tput sgr0)
  ;;
 underline)
  #yes i know its not a color, its still usefull though.
  shift 1
  echo $(tput setaf smul)${*}$(tput sgr0)
  ;;
 custom)
  color_code=${2}
  shift 2
  echo $(tput setaf ${color_code})${*}$(tput sgr0)
  ;;
 ls-color-codes)
  for i in $(seq 0 256); do 
  tput setaf ${i}
  printf " %3s" "$i"
  tput sgr0
  if [ $((($i + 1) % 16)) == 0 ] ; then
   echo #New line
  fi
  done 
  ;;
 *)
  cat <
This script will echo your text as a specified color.

Usage:
 $0
 $0 custom
 $0 ls-color-codes
USAGE
 esac
}
echo_color $*
I'm particularly happy with my ls-color-codes argument, it will print a 16x16 box of the color codes and their colors.

Happy scripting!