Tuesday, January 10, 2012

Homebrew and pianobar

PromyLOPh pushed a patch today to fix pianobar so it would be compatible with a recent protocol change. Apparently Pandora has changed from using TLS to not using TLS...Well thats all fine and great but I use homebrew for mac to maintain my packages. I wanted my pianobar updated NAOW. so i started looking around...

-First i ran "locate pianobar" to get an idea of where the files were located.
-"/usr/local/Library/Formula/pianobar.rb" caught my eye so i looked into it...
- The ruby file has a few entries in it, but towards the top is this code:
class Pianobar < Formula
url 'https://github.com/PromyLOPh/pianobar/tarball/2011.12.11'
version '2011.12.11'
homepage 'https://github.com/PromyLOPh/pianobar/'
md5 'c8573c133851ff54649d1ab45c7b855c'

-this obviously looks like where it tells homebrew to download and install the program. so what happens if I change those values to reflect the most current version?
-I opened the ruby file in vim and changed the settings:
class Pianobar < Formula
url 'https://github.com/PromyLOPh/pianobar/tarball/2012.01.10'
version '2012.01.10'
homepage 'https://github.com/PromyLOPh/pianobar/'
md5 'a703227c079cb0fe20ac4abbdfbc6f08'

-saved, and ran "brew upgrade pianobar"

==> Upgrading pianobar
==> Downloading https://github.com/PromyLOPh/pianobar/tarball/2012.01.10
######################################################################## 100.0%
==> make PREFIX=/usr/local/Cellar/pianobar/2012.01.10
==> make install PREFIX=/usr/local/Cellar/pianobar/2012.01.10
/usr/local/Cellar/pianobar/2012.01.10: 16 files, 176K, built in 3 seconds

-awwww yeahhhhh now i have my crack back in my spoon.

Sunday, December 25, 2011

What Linux distro/version is running

Most people know about uname -a to get a good amount of information. However, if you want an easy way to discover the distro/version you can run:

cat /etc/issue

The problem is that /etc/issue was never meant to keep track of the release version. So it may not exist on certain machines. I believe the most reliable method would be to:

cat /etc/*release

or

lsb_release -a

Wednesday, December 14, 2011

Downloading DefCon Videos - The Easy Way

curl & wget is your friend.

The following commands will get you the download links for the different defcon videos they allow for download on their site.

Defcon 19
curl "http://defcon.org/html/links/dc-archives/dc-19-archive.html" | grep -o "https.*\.m4v"
Defcon 18
curl "http://defcon.org/html/links/dc-archives/dc-18-archive.html" | grep -o "https.*\.m4v"
Defcon 17
curl "http://defcon.org/html/links/dc-archives/dc-17-archive.html" | grep -o "https.*Video.*\.m4v\"
Defcon 16
curl "http://defcon.org/html/links/dc-archives/dc-16-archive.html" | grep -o "https.*m4v\"" | cut -d ' ' -f1 | tr -d '"'
Defcon 15
curl "http://defcon.org/html/links/dc-archives/dc-15-archive.html" | grep -o "http://media.*\.m4v"
Defcon 14
curl "http://defcon.org/html/links/dc-archives/dc-14-archive.html" | grep -o "https.*\.m4v"
Defcon 13
curl "http://defcon.org/html/links/dc-archives/dc-13-archive.html" | grep -o "https.*\.m4v"
Defcon 12
curl "http://defcon.org/html/links/dc-archives/dc-12-archive.html" | grep -o "https.*\.m4v"
Defcon 11
curl "http://defcon.org/html/links/dc-archives/dc-11-archive.html" | grep -o "https.*\.m4v"
Defcon 10
curl "http://defcon.org/html/links/dc-archives/dc-10-archive.html" | grep -o "https.*\.m4v"
Defcon 9
curl "http://defcon.org/html/links/dc-archives/dc-9-archive.html" | grep -o "https.*\.m4v"
Defcon 8
curl "http://defcon.org/html/links/dc-archives/dc-8-archive.html" | grep -o "https.*\.m4v"
Defcon 7
curl "http://defcon.org/html/links/dc-archives/dc-7-archive.html" | grep -o "https.*\.m4v"

Wednesday, November 30, 2011

Telnet awesomeness

Saw this on reddit. I love geeks:

telnet miku.acm.uiuc.edu

Tuesday, November 29, 2011

Prepending text to a file

no mo' temp files

echo lol > rofl.txt
echo wut | cat - rofl.txt | tee rofl.txt > /dev/null

this makes cat concatenate firstly the stdin, which in this case is the piped output from echo, and then the file you prepend it to then redirects that stdout to tee which outputs it to the original file.


Move running process to screen

ctrl+z #to suspend
bg #to background
screen retty $PID #to move the PID to screen

install retty using apt-get

Python & ruby saves json output

At first I was disgusted by json output. then python made it pretty. thanks python

cat t2.json | python -mjson.tool
you can do the same thing with ruby albeit longer:
cat t2.json | ruby -e "require 'rubygems'; require 'json'; puts JSON.pretty_generate(JSON[STDIN.read]);"

Dumping GNU screen output

I like to have a copy of my screen sessions as a text file for future reference and reporting when i do my pentests.

while in screen type c-a :hardcopy -h dumpofwindow1

this should create a file "dumpofwindow1" in the home dir.

You can view it with cat

*-h dumps the entire scrollback buffer. its improtant to remember that its useless if you are in less or vi or something similar.


Wednesday, November 23, 2011

Understanding the BASH fork bomb

:(){ :|:& }


is a good old fashion troll against noobs in linux. The above command basically sets up a function named ":" - This trips up noobies because they dont quite get what that is, the dont realize that functions can be named almost anything, not just conventional names like myFunction().

The core of the function basically sets up a pipe and runs in the background that constantly runs and runs again. Thereby using up all the resources on the machine extremely quickly. The funny part is if they try to perform some action to free up resources, the function simply uses up those resources again.

Its a classic.

Ghetto locate

some boxes dont have locate/updatedb on them for indexed searching of the filesystem. This sucks when you need to look for several files. You can create your own ghetto version by:

find / -print > filesystemlisting
and then grepping through that for your entries.
the find command just outputs the entire filesystem names to that file as absolute paths.
easy smeasy