Friday, November 4, 2011

Colorize the Output of any Command from Bash!


# git clone git://github.com/ninp0/console_crayon.git
# gem install rainbow

I particularly like using it with tcpdump when monitoring pf in realtime via OpenBSD:

# cd console_crayon && ./console_crayon.rb -c 'tcpdump -nettt -i pflog0' -m 'pass,green,white|block,red,white'

but I'm sure you could use it for a million other things...enjoy!

Cheers!

Wednesday, October 12, 2011

Wiping Up the Web, One Tissue (i.e. Page) at a Time...Introducing, "hachoo.rb"

A helpful utility if you want to explore web pages in detail...should work with tor, socks, MITM proxies, etc.

* Features: Site automation, proxy support (including SOCKS), ability to change user agent, iframe support, etc...
*Coming soon: (crawling, bug-fixes, etc)

I welcome any suggestions for improvement.  Cheers!

Installation:

# git clone git://github.com/ninp0/hachoo.git
# gem install mechanize
# gem install addressable
# gem install socksify
# gem install rails
# cd hachoo
# ./hachoo.rb
Usage: ./hachoo.rb -u <uri> <optional_flags>
    -h, --help                       Help!
    -u, --uri URI                    Required: Target URI
    -P, --proxy-ip PROXY_IP          Optional: Proxy IP
    -p, --proxy-port PROXY_PORT      Optional: Proxy Port
    -S, --enable-socks-proxy         Optional: Soxy Proxy is Foxy ;)
    -a, --eval-all                   Optional: Evaluate All
    -b, --body-eval                  Optional: Evaluate Body Response
    -f, --forms-eval                 Optional: Evaluate Forms
    -l, --links-eval                 Optional: Evaluate Links
    -i, --images-eval                Optional: Evaluate Images
    -t, --title-eval                 Optional: Display Page Title
    -T, --timeout SECONDS            Optional: Timeout in Seconds
    -U, --user-agent AGENT           Optional: User Agent

Basic Example (Request will Timeout After 5 Seconds):
    ./hachoo.rb -u https://twitter.com/ninp0 -a -T 5

Intermediate Example:
    Start a MITM Proxy (e.g. BurpSuite, Paros, etc.)
        java -Xmx512m -jar burpsuite.jar
    Now perform a Request on the URL Below via the MITM Proxy:
        ./hachoo.rb -P '127.0.0.1' -p 8080 -u 'http://hang4r.blogspot.com'

Advanced Example:
    Start a SOCKS Server vis SSH:
        ssh -v -v -v -NCD 127.0.0.1:8443 user@remote_ssh_host
    Use hachoo.rb to Search for WordPress Sitesi
    through a SOCKS Proxy via Google Trickery:
        ./hachoo.rb -S -P '127.0.0.1' -p 8443 -u 'http://www.google.com/search?sclient=psy-ab&q=inurl:wp-content%20site:wordpress.org' -l

Kung-Fu Example:
    Use hachoo.rb to Follow ninp0 on Twitter via Pipe-Delimited Stacked Requests (Replace USERNAME & PASSWORD in Example Below):
    Despite the 404 Response for this Stacked Request ninp0 will be Followed...
        ./hachoo.rb -u 'https://mobile.twitter.com/login>>>submit>>>username=USERNAME&password=PASSWORD|https://mobile.twitter.com/ninp0>>>get|https://mobile.twitter.com/ninp0/follow>>>submit>>>last_url=/ninp0'

Wednesday, August 24, 2011

Grokking CSVs Easier in STDOUT

#!/usr/bin/env ruby
require 'rainbow' # To make things a bit more readable
require 'csv' # using just split won't work cause of \n in some fields

if ARGV[0].nil?
 puts "#{$0} <csv_file>"
 exit
end
i = 0
headers = []
header_index = 0
CSV.foreach(ARGV[0], :quote_char => '"', :col_sep =>',', :row_sep =>:auto) do |line|
 line.each do |column|
   if i == 0
     headers.push(column)
   end
   if i % 2 == 0
     puts headers[header_index].upcase
     puts "#{column}\n"
   else
     puts headers[header_index].upcase.inverse
     puts "#{column}\n".inverse
   end
   header_index += 1
 end
 header_index = 0
 i += 1
end

Tuesday, August 2, 2011

Enabling Remote X11 Forwarding Over SSH Despite IPv6 Bug

Run ps -ef | grep X on your X client (the remote box) and your X server (in this case, you local machine in which you intend to have the GUI application displayed)

Your output SHOULD look very similar to this:
/usr/bin/X :0 vt07 -nolisten tcp

It is perfectly acceptable that the -nolisten tcp is enabled and running on both the X client and X server

/etc/ssh/ssh_config (Your local machine i.e. your ssh client)
Host *
ForwardAgent no
ForwardX11 yes
ForwardX11Trusted no

/etc/ssh/sshd_config (Your sshd server i.e. your remote ssh server)
X11Forwarding yes
X11DisplayOffset 10

Try running xclock.  At this point, I was getting:

Error: Can't find display

And running:

echo $DISPLAY

resulted in nothing.

If you experience similar issues, you've configured the options in /etc/ssh/ssh_config & /etc/ssh/sshd_config, and get the following error when authenticating with your ssh server (evident on sshd server by running tail -f /var/log/auth.log):

error: Failed to allocate internet-domain X11 display socket.

Then ensure the following is configured within /etc/ssh/sshd_config:

AddressFamily inet

Restart your sshd server:

/etc/init.d/sshd restart

Exit your shell by hitting CTRL+d

Re-authenticate:

ssh -X <user>@<host>

echo $DISPLAY

and you should see:

localhost:10.0

Run xlock and viola!  Awesomeness.  Cheers!

Monday, August 1, 2011

Converting IPv4 Addresses into Memory Addresses

This is helpful when you're writing your own Metasploit modules with custom shellcode:

#!/usr/bin/env ruby
# Enjoy ;)
ip = ARGV[0]
if ip.split(".").count == 4
  print "0x"
  ip.split(".").reverse.each do |octet|
    print "%02x" % octet.to_i
  end
  print "\n"
else
  puts "Invalid IPv4 Address"
end

Tuesday, July 26, 2011

Dynamically Attaching MULTIPLE Files to Emails in Ruby Using Pony

I struggled with this one a bit, so I figured I'd share it with those that may be in a similar place.  Okay, so here was the goal - obtain the directory listings of a folder (which contained folders named after recipients) and recursively find every file in the recipient folder.  Once a file(s) is found in the corresponding recipient folder, add the file(s) as an attachment to one email.  Pheww, that can take the breath out of a person.  If you have a better way of accomplishing this goal, then please share! :) 

#!/usr/bin/env ruby
require 'pony'
smtp_relay = "smtp_relay.somedomain.com"
name_root = “~/my_mail_list_dir/”
attachment_hash = {}
Dir.entries(name_root).each do |name|
  # Replace message text with name
  msg_body = File.read("~/email_msg.txt").gsub("NAME_OF_PERSON", name)

  # Recurse each name folder and find corresponding files to add as attachments 

  Dir["#{name_root}/#{name}/**"].each do |attachment|
    if File.file?(current_attachment) == true
      current_attachment_name = File.basename(current_attachment)
      attachment_hash["#{current_attachment_name}"] = "#{File.binread(current_attachment)}"
    end
  end

  Pony.mail(
    :to => "destination@domain.com",
    :from => "source@otherdestination.com",
    :subject => "The Subject",
    :body => msg_body,
    :attachments => attachment_hash,
    :via => :smtp,
    # It's important to note that you should use SMTPS (TCP port 465) 

    # whenever possible - I only had a inadequate SMTP (TCP port 25)
    # relay at my disposal at the time of this writing
    :via_options => {
      :address => smtp_relay,
      :port => 25,
      :enable_starttls_auto => false
    }
  )

  # Reset attachments for new owner
  attachment_hash = {}
end


Hope it helps ya! Cheers!

Monday, July 25, 2011

The Beauty of Using "apt-file" whilst Dealing with Dependencies whilst Compiling Software

Let's take an example - compiling hydra.  Hydra is "a very fast network logon cracker which support many different services."  Hydra can be found at:
http://thc.org/thc-hydra/

For this exercise we used the following direct links:
http://www.thc.org/releases/hydra-6.5-src.tar.gz
http://thc.org/thc-hydra/hydra-6.5-fix.diff

Let's get started.  First, install apt-file:

root@hostname:~# apt-get install apt-file
update its database
root@hostname:~# apt-file update
now let the configuring begin:

root@hostname:~# mkdir hydra
root@hostname:~# cd hydra
root@hostname:~/hydra# ls
root@hostname:~/hydra# wget http://www.thc.org/releases/hydra-6.5-src.tar.gz
--2011-07-25 20:47:18--  http://www.thc.org/releases/hydra-6.5-src.tar.gz
Resolving www.thc.org... 199.58.210.16
Connecting to www.thc.org|199.58.210.16|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 633851 (619K) [application/x-gzip]
Saving to: `hydra-6.5-src.tar.gz'

100%[===========================================================================================================>] 633,851      402K/s   in 1.5s   

2011-07-25 20:47:20 (402 KB/s) - `hydra-6.5-src.tar.gz' saved [633851/633851]

root@hostname:~/hydra# wget http://thc.org/thc-hydra/hydra-6.5-fix.diff
--2011-07-25 20:47:28--  http://thc.org/thc-hydra/hydra-6.5-fix.diff
Resolving thc.org... 199.58.210.16
Connecting to thc.org|199.58.210.16|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1671 (1.6K) [text/plain]
Saving to: `hydra-6.5-fix.diff'

100%[===========================================================================================================>] 1,671       --.-K/s   in 0s     

2011-07-25 20:47:29 (129 MB/s) - `hydra-6.5-fix.diff' saved [1671/1671]

root@hostname:~/hydra# ls
hydra-6.5-fix.diff  hydra-6.5-src.tar.gz
root@hostname:~/hydra# tar xzvf hydra-6.5-src.tar.gz
hydra-6.5-src/
hydra-6.5-src/bfg.c
hydra-6.5-src/bfg.h
hydra-6.5-src/CHANGES
hydra-6.5-src/configure
hydra-6.5-src/crc32.c
hydra-6.5-src/crc32.h
hydra-6.5-src/d3des.c
hydra-6.5-src/d3des.h
hydra-6.5-src/dpl4hydra.sh
hydra-6.5-src/dpl4hydra_full.csv
hydra-6.5-src/dpl4hydra_local.csv
hydra-6.5-src/hmacmd5.c
hydra-6.5-src/hmacmd5.h
hydra-6.5-src/hydra-afp.c
hydra-6.5-src/hydra-cisco-enable.c
hydra-6.5-src/hydra-cisco.c
hydra-6.5-src/hydra-cvs.c
hydra-6.5-src/hydra-firebird.c
hydra-6.5-src/hydra-ftp.c
hydra-6.5-src/hydra-gtk/
hydra-6.5-src/hydra-gtk/acconfig.h
hydra-6.5-src/hydra-gtk/aclocal.m4
hydra-6.5-src/hydra-gtk/AUTHORS
hydra-6.5-src/hydra-gtk/autogen.sh
hydra-6.5-src/hydra-gtk/ChangeLog
hydra-6.5-src/hydra-gtk/config.h
hydra-6.5-src/hydra-gtk/config.h.in
hydra-6.5-src/hydra-gtk/configure
hydra-6.5-src/hydra-gtk/configure.in
hydra-6.5-src/hydra-gtk/COPYING
hydra-6.5-src/hydra-gtk/INSTALL
hydra-6.5-src/hydra-gtk/install-sh
hydra-6.5-src/hydra-gtk/Makefile.am
hydra-6.5-src/hydra-gtk/Makefile.in
hydra-6.5-src/hydra-gtk/make_xhydra.sh
hydra-6.5-src/hydra-gtk/missing
hydra-6.5-src/hydra-gtk/mkinstalldirs
hydra-6.5-src/hydra-gtk/NEWS
hydra-6.5-src/hydra-gtk/README
hydra-6.5-src/hydra-gtk/src/
hydra-6.5-src/hydra-gtk/src/callbacks.c
hydra-6.5-src/hydra-gtk/src/callbacks.h
hydra-6.5-src/hydra-gtk/src/interface.c
hydra-6.5-src/hydra-gtk/src/interface.h
hydra-6.5-src/hydra-gtk/src/main.c
hydra-6.5-src/hydra-gtk/src/Makefile.am
hydra-6.5-src/hydra-gtk/src/Makefile.in
hydra-6.5-src/hydra-gtk/src/support.c
hydra-6.5-src/hydra-gtk/src/support.h
hydra-6.5-src/hydra-gtk/stamp-h.in
hydra-6.5-src/hydra-gtk/xhydra.glade
hydra-6.5-src/hydra-gtk/xhydra.gladep
hydra-6.5-src/hydra-http-form.c
hydra-6.5-src/hydra-http-proxy.c
hydra-6.5-src/hydra-http.c
hydra-6.5-src/hydra-icq.c
hydra-6.5-src/hydra-imap.c
hydra-6.5-src/hydra-irc.c
hydra-6.5-src/hydra-ldap.c
hydra-6.5-src/hydra-logo.ico
hydra-6.5-src/hydra-logo.rc
hydra-6.5-src/hydra-mod.c
hydra-6.5-src/hydra-mod.h
hydra-6.5-src/hydra-mssql.c
hydra-6.5-src/hydra-mysql.c
hydra-6.5-src/hydra-ncp.c
hydra-6.5-src/hydra-nntp.c
hydra-6.5-src/hydra-oracle-listener.c
hydra-6.5-src/hydra-oracle-sid.c
hydra-6.5-src/hydra-oracle.c
hydra-6.5-src/hydra-pcanywhere.c
hydra-6.5-src/hydra-pcnfs.c
hydra-6.5-src/hydra-pop3.c
hydra-6.5-src/hydra-postgres.c
hydra-6.5-src/hydra-rexec.c
hydra-6.5-src/hydra-rlogin.c
hydra-6.5-src/hydra-rsh.c
hydra-6.5-src/hydra-sapr3.c
hydra-6.5-src/hydra-sip.c
hydra-6.5-src/hydra-smb.c
hydra-6.5-src/hydra-smtp-enum.c
hydra-6.5-src/hydra-smtp.c
hydra-6.5-src/hydra-snmp.c
hydra-6.5-src/hydra-socks5.c
hydra-6.5-src/hydra-ssh.c
hydra-6.5-src/hydra-svn.c
hydra-6.5-src/hydra-teamspeak.c
hydra-6.5-src/hydra-telnet.c
hydra-6.5-src/hydra-vmauthd.c
hydra-6.5-src/hydra-vnc.c
hydra-6.5-src/hydra-xmpp.c
hydra-6.5-src/hydra.1
hydra-6.5-src/hydra.c
hydra-6.5-src/hydra.h
hydra-6.5-src/INSTALL
hydra-6.5-src/libpq-fe.h
hydra-6.5-src/LICENSE
hydra-6.5-src/LICENSE.OPENSSL
hydra-6.5-src/Makefile.am
hydra-6.5-src/Makefile.unix
hydra-6.5-src/ntlm.c
hydra-6.5-src/ntlm.h
hydra-6.5-src/performance.h
hydra-6.5-src/postgres_ext.h
hydra-6.5-src/pw-inspector-logo.rc
hydra-6.5-src/pw-inspector.1
hydra-6.5-src/pw-inspector.c
hydra-6.5-src/pw-inspector.ico
hydra-6.5-src/README
hydra-6.5-src/sasl.c
hydra-6.5-src/sasl.h
hydra-6.5-src/xhydra.1
hydra-6.5-src/xhydra.png
root@hostname:~/hydra# lls
No command 'lls' found, but there are 16 similar ones
lls: command not found
root@hostname:~/hydra# ^C
root@hostname:~/hydra# ls
hydra-6.5-fix.diff  hydra-6.5-src  hydra-6.5-src.tar.gz
root@hostname:~/hydra# cd hydra-6.5-src/
root@hostname:~/hydra/hydra-6.5-src# ls
bfg.c                hmacmd5.h             hydra-http-form.c   hydra-ncp.c              hydra-sapr3.c      hydra-vnc.c      pw-inspector.1
bfg.h                hydra.1               hydra-http-proxy.c  hydra-nntp.c             hydra-sip.c        hydra-xmpp.c     pw-inspector.c
CHANGES              hydra-afp.c           hydra-icq.c         hydra-oracle.c           hydra-smb.c        INSTALL          pw-inspector.ico
configure            hydra.c               hydra-imap.c        hydra-oracle-listener.c  hydra-smtp.c       libpq-fe.h       pw-inspector-logo.rc
crc32.c              hydra-cisco.c         hydra-irc.c         hydra-oracle-sid.c       hydra-smtp-enum.c  LICENSE          README
crc32.h              hydra-cisco-enable.c  hydra-ldap.c        hydra-pcanywhere.c       hydra-snmp.c       LICENSE.OPENSSL  sasl.c
d3des.c              hydra-cvs.c           hydra-logo.ico      hydra-pcnfs.c            hydra-socks5.c     Makefile.am      sasl.h
d3des.h              hydra-firebird.c      hydra-logo.rc       hydra-pop3.c             hydra-ssh.c        Makefile.unix    xhydra.1
dpl4hydra_full.csv   hydra-ftp.c           hydra-mod.c         hydra-postgres.c         hydra-svn.c        ntlm.c           xhydra.png
dpl4hydra_local.csv  hydra-gtk             hydra-mod.h         hydra-rexec.c            hydra-teamspeak.c  ntlm.h
dpl4hydra.sh         hydra.h               hydra-mssql.c       hydra-rlogin.c           hydra-telnet.c     performance.h
hmacmd5.c            hydra-http.c          hydra-mysql.c       hydra-rsh.c              hydra-vmauthd.c    postgres_ext.h
root@hostname:~/hydra/hydra-6.5-src# ./configure

Starting hydra auto configuration ...
Detected 64 Bit Linux OS

Checking for openssl (libssl, libcrypto, ssl.h, sha.h) ...
                                                       ... found
Checking for idn (libidn.so) ...
                             ... found
Checking for pcre (libpcre.so, pcre.h) ...
                                       ... found
Checking for Postgres (libpq.so, libpq-fe.h) ...
                                             ... found
Checking for SVN (libsvn_client-1 libapr-1.so libaprutil-1.so) ...
                                                               ... NOT found, module svn disabled
Checking for firebird (libfbclient.so) ...
                                       ... NOT found, module firebird disabled
Checking for MYSQL client (libmysqlclient.so, math.h) ...
                                                      ... found
Checking for AFP (libafpclient.so) ...
                                   ... NOT found, module Apple Filing Protocol disabled - Apple sucks anyway
Checking for NCP (libncp.so / nwcalls.h) ...
                                         ... NOT found, module NCP disabled
Checking for SAP/R3 (librfc/saprfc.h) ...
                                      ... NOT found, module sapr3 disabled
Get it from http://www.sap.com/solutions/netweaver/linux/eval/index.asp
Checking for libssh (libssh/libssh.h) ...
                                      ... NOT found, module ssh disabled
Get it from http://www.libssh.org
Checking for Oracle (libocci.so libclntsh.so / oci.h) ...
                                                      ... NOT found, module Oracle disabled
Checking for GUI req's (pkg-config, gtk+-2.0) ...
                                              ... found

Hydra will be installed into .../bin of: ~
  (change this by running ./configure --prefix=path)

Writing Makefile.in ...
now type "make"
root@hostname:~/hydra/hydra-6.5-src# apt-file search libsvn_client-1
libsvn-dev: /usr/lib/libsvn_client-1.a
libsvn-dev: /usr/lib/libsvn_client-1.la
libsvn-dev: /usr/lib/libsvn_client-1.so
libsvn1: /usr/lib/libsvn_client-1.so.1
libsvn1: /usr/lib/libsvn_client-1.so.1.0.0
root@hostname:~/hydra/hydra-6.5-src# ainstall libsvn-dev
Reading package lists... Done
Building dependency tree      
Reading state information... Done
Suggested packages:
  libsvn-doc libneon27-gnutls-dev
The following NEW packages will be installed:
  libsvn-dev
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 1,207 kB of archives.
After this operation, 4,686 kB of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com/ubuntu/ natty-updates/main libsvn-dev amd64 1.6.12dfsg-4ubuntu2.1 [1,207 kB]
Fetched 1,207 kB in 5s (211 kB/s)      
Selecting previously deselected package libsvn-dev.
(Reading database ... 313175 files and directories currently installed.)
Unpacking libsvn-dev (from .../libsvn-dev_1.6.12dfsg-4ubuntu2.1_amd64.deb) ...
Setting up libsvn-dev (1.6.12dfsg-4ubuntu2.1) ...
root@hostname:~/hydra/hydra-6.5-src# ./configure

Starting hydra auto configuration ...
Detected 64 Bit Linux OS

Checking for openssl (libssl, libcrypto, ssl.h, sha.h) ...
                                                       ... found
Checking for idn (libidn.so) ...
                             ... found
Checking for pcre (libpcre.so, pcre.h) ...
                                       ... found
Checking for Postgres (libpq.so, libpq-fe.h) ...
                                             ... found
Checking for SVN (libsvn_client-1 libapr-1.so libaprutil-1.so) ...
                                                               ... found
Checking for firebird (libfbclient.so) ...
                                       ... NOT found, module firebird disabled
Checking for MYSQL client (libmysqlclient.so, math.h) ...
                                                      ... found
Checking for AFP (libafpclient.so) ...
                                   ... NOT found, module Apple Filing Protocol disabled - Apple sucks anyway
Checking for NCP (libncp.so / nwcalls.h) ...
                                         ... NOT found, module NCP disabled
Checking for SAP/R3 (librfc/saprfc.h) ...
                                      ... NOT found, module sapr3 disabled
Get it from http://www.sap.com/solutions/netweaver/linux/eval/index.asp
Checking for libssh (libssh/libssh.h) ...
                                      ... NOT found, module ssh disabled
Get it from http://www.libssh.org
Checking for Oracle (libocci.so libclntsh.so / oci.h) ...
                                                      ... NOT found, module Oracle disabled
Checking for GUI req's (pkg-config, gtk+-2.0) ...
                                              ... found

Hydra will be installed into .../bin of: ~
  (change this by running ./configure --prefix=path)

Writing Makefile.in ...
now type "make"
root@hostname:~/hydra/hydra-6.5-src# apt-file search libfbclient.so
firebird2.1-dev: /usr/lib/libfbclient.so
firebird2.5-dev: /usr/lib/libfbclient.so
firebird2.5-super-dbg: /usr/lib/debug/usr/lib/libfbclient.so.2.5.0
libfbclient2: /usr/lib/libfbclient.so.2
libfbclient2: /usr/lib/libfbclient.so.2.5.0
root@hostname:~/hydra/hydra-6.5-src# acache firebird2.5-dev
firebird2.5-dev - Development files for Firebird - an RDBMS based on InterBase 6.0 code
root@hostname:~/hydra/hydra-6.5-src# ainstall firebird2.5-dev
Reading package lists... Done
Building dependency tree      
Reading state information... Done
The following extra packages will be installed:
  firebird2.5-common firebird2.5-common-doc libfbclient2 libib-util
Suggested packages:
  libfbembed2.5 firebird2.5-examples
The following NEW packages will be installed:
  firebird2.5-common firebird2.5-common-doc firebird2.5-dev libfbclient2 libib-util
0 upgraded, 5 newly installed, 0 to remove and 0 not upgraded.
Need to get 929 kB of archives.
After this operation, 3,617 kB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://us.archive.ubuntu.com/ubuntu/ natty/universe firebird2.5-common-doc all 2.5.0.26074-0.ds4-4 [35.1 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu/ natty/universe firebird2.5-common amd64 2.5.0.26074-0.ds4-4 [490 kB]
Get:3 http://us.archive.ubuntu.com/ubuntu/ natty/universe libfbclient2 amd64 2.5.0.26074-0.ds4-4 [335 kB]
Get:4 http://us.archive.ubuntu.com/ubuntu/ natty/universe libib-util amd64 2.5.0.26074-0.ds4-4 [3,866 B]
Get:5 http://us.archive.ubuntu.com/ubuntu/ natty/universe firebird2.5-dev all 2.5.0.26074-0.ds4-4 [65.0 kB]
Fetched 929 kB in 4s (206 kB/s)        
Selecting previously deselected package firebird2.5-common-doc.
(Reading database ... 313257 files and directories currently installed.)
Unpacking firebird2.5-common-doc (from .../firebird2.5-common-doc_2.5.0.26074-0.ds4-4_all.deb) ...
Selecting previously deselected package firebird2.5-common.
Unpacking firebird2.5-common (from .../firebird2.5-common_2.5.0.26074-0.ds4-4_amd64.deb) ...
Selecting previously deselected package libfbclient2.
Unpacking libfbclient2 (from .../libfbclient2_2.5.0.26074-0.ds4-4_amd64.deb) ...
Selecting previously deselected package libib-util.
Unpacking libib-util (from .../libib-util_2.5.0.26074-0.ds4-4_amd64.deb) ...
Selecting previously deselected package firebird2.5-dev.
Unpacking firebird2.5-dev (from .../firebird2.5-dev_2.5.0.26074-0.ds4-4_all.deb) ...
Setting up firebird2.5-common-doc (2.5.0.26074-0.ds4-4) ...
Setting up firebird2.5-common (2.5.0.26074-0.ds4-4) ...
Setting up libfbclient2 (2.5.0.26074-0.ds4-4) ...
Setting up libib-util (2.5.0.26074-0.ds4-4) ...
Setting up firebird2.5-dev (2.5.0.26074-0.ds4-4) ...
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place
root@hostname:~/hydra/hydra-6.5-src# acache firebird2.5-dev
^C^[[A^[[A
root@hostname:~/hydra/hydra-6.5-src# ./configure
Starting hydra auto configuration ...
Detected 64 Bit Linux OS

Checking for openssl (libssl, libcrypto, ssl.h, sha.h) ...
                                                       ... found
Checking for idn (libidn.so) ...
                             ... found
Checking for pcre (libpcre.so, pcre.h) ...
                                       ... found
Checking for Postgres (libpq.so, libpq-fe.h) ...
                                             ... found
Checking for SVN (libsvn_client-1 libapr-1.so libaprutil-1.so) ...
                                                               ... found
Checking for firebird (libfbclient.so) ...
                                       ... found
Checking for MYSQL client (libmysqlclient.so, math.h) ...
                                                      ... found
Checking for AFP (libafpclient.so) ...
                                   ... NOT found, module Apple Filing Protocol disabled - Apple sucks anyway
Checking for NCP (libncp.so / nwcalls.h) ...
                                         ... NOT found, module NCP disabled
Checking for SAP/R3 (librfc/saprfc.h) ...
                                      ... NOT found, module sapr3 disabled
Get it from http://www.sap.com/solutions/netweaver/linux/eval/index.asp
Checking for libssh (libssh/libssh.h) ...
                                      ... NOT found, module ssh disabled
Get it from http://www.libssh.org
Checking for Oracle (libocci.so libclntsh.so / oci.h) ...
                                                      ... NOT found, module Oracle disabled
Checking for GUI req's (pkg-config, gtk+-2.0) ...
                                              ... found

Hydra will be installed into .../bin of: ~
  (change this by running ./configure --prefix=path)

Writing Makefile.in ...
now type "make"
root@hostname:~/hydra/hydra-6.5-src# apt-file search libafpclient.so
root@hostname:~/hydra/hydra-6.5-src# apt-file search libncp.so
libncp: /usr/lib/libncp.so
libncp: /usr/lib/libncp.so.2.3
libncp: /usr/lib/libncp.so.2.3.0
root@hostname:~/hydra/hydra-6.5-src# ainstall libncp
Reading package lists... Done
Building dependency tree      
Reading state information... Done
The following NEW packages will be installed:
  libncp
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 184 kB of archives.
After this operation, 434 kB of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com/ubuntu/ natty/universe libncp amd64 2.2.6-8 [184 kB]
Fetched 184 kB in 2s (83.2 kB/s)
Selecting previously deselected package libncp.
(Reading database ... 313294 files and directories currently installed.)
Unpacking libncp (from .../libncp_2.2.6-8_amd64.deb) ...
Setting up libncp (2.2.6-8) ...
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place
/sbin/ldconfig.real: ~/lib/libmapnik.so.0.6 is not a symbolic link

/sbin/ldconfig.real: /opt/rapid7/nexpose/nsc/nxpgsql/pgsql/lib/libpgtypes.so.2 is not a symbolic link

/sbin/ldconfig.real: /opt/rapid7/nexpose/nsc/nxpgsql/pgsql/lib/libecpg.so.5 is not a symbolic link

/sbin/ldconfig.real: /opt/rapid7/nexpose/nsc/nxpgsql/pgsql/lib/libecpg_compat.so.2 is not a symbolic link

/sbin/ldconfig.real: /opt/rapid7/nexpose/nsc/nxpgsql/pgsql/lib/libpq.so.5 is not a symbolic link

root@hostname:~/hydra/hydra-6.5-src# apt-file search saprfc.h
root@hostname:~/hydra/hydra-6.5-src# apt-cache search libssh.h
root@hostname:~/hydra/hydra-6.5-src# apt-file search libssh.h
libssh-dev: /usr/include/libssh/libssh.h
root@hostname:~/hydra/hydra-6.5-src# ainstall libssh-dev
Reading package lists... Done
Building dependency tree      
Reading state information... Done
Suggested packages:
  libssh-doc
The following NEW packages will be installed:
  libssh-dev
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 145 kB of archives.
After this operation, 582 kB of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com/ubuntu/ natty/main libssh-dev amd64 0.4.5-3ubuntu1 [145 kB]
Fetched 145 kB in 1s (72.5 kB/s)    
Selecting previously deselected package libssh-dev.
(Reading database ... 313302 files and directories currently installed.)
Unpacking libssh-dev (from .../libssh-dev_0.4.5-3ubuntu1_amd64.deb) ...
Setting up libssh-dev (0.4.5-3ubuntu1) ...
root@hostname:~/hydra/hydra-6.5-src# ls -l
total 1860
-rw-r--r-- 1 nxpgsql  513   7092 2011-07-15 04:17 bfg.c
-rw-r--r-- 1 nxpgsql  513   2125 2011-07-15 04:17 bfg.h
-rw-r--r-- 1 nxpgsql  513  23800 2011-07-15 04:17 CHANGES
-rwxr-xr-x 1 nxpgsql  513  22783 2011-07-15 04:17 configure
-rw-r--r-- 1 nxpgsql  513   5395 2011-07-15 04:17 crc32.c
-rw-r--r-- 1 nxpgsql  513    121 2011-07-15 04:17 crc32.h
-rw-r--r-- 1 nxpgsql  513  16034 2011-07-15 04:17 d3des.c
-rw-r--r-- 1 nxpgsql  513   1651 2011-07-15 04:17 d3des.h
-rw-r--r-- 1 nxpgsql  513 334144 2011-07-15 04:17 dpl4hydra_full.csv
-rw-r--r-- 1 nxpgsql  513 334144 2011-07-15 04:17 dpl4hydra_local.csv
-rwxr-xr-x 1 nxpgsql  513   5860 2011-07-15 04:17 dpl4hydra.sh
-rw-r--r-- 1 nxpgsql  513   4461 2011-07-15 04:17 hmacmd5.c
-rw-r--r-- 1 nxpgsql  513   1489 2011-07-15 04:17 hmacmd5.h
-rw-r--r-- 1 nxpgsql  513   2995 2011-07-15 04:17 hydra.1
-rw-r--r-- 1 nxpgsql  513   4251 2011-07-15 04:17 hydra-afp.c
-rw-r--r-- 1 nxpgsql  513 126282 2011-07-15 04:17 hydra.c
-rw-r--r-- 1 nxpgsql  513   4459 2011-07-15 04:17 hydra-cisco.c
-rw-r--r-- 1 nxpgsql  513   5887 2011-07-15 04:17 hydra-cisco-enable.c
-rw-r--r-- 1 nxpgsql  513   4248 2011-07-15 04:17 hydra-cvs.c
-rw-r--r-- 1 nxpgsql  513   3570 2011-07-15 04:17 hydra-firebird.c
-rw-r--r-- 1 nxpgsql  513   5162 2011-07-15 04:17 hydra-ftp.c
drwxr-xr-x 3 nxpgsql  513   4096 2011-07-15 04:17 hydra-gtk
-rw-r--r-- 1 nxpgsql  513   2659 2011-07-15 04:17 hydra.h
-rw-r--r-- 1 nxpgsql  513   9341 2011-07-15 04:17 hydra-http.c
-rw-r--r-- 1 nxpgsql  513  20516 2011-07-15 04:17 hydra-http-form.c
-rw-r--r-- 1 nxpgsql  513   7057 2011-07-15 04:17 hydra-http-proxy.c
-rw-r--r-- 1 nxpgsql  513   6528 2011-07-15 04:17 hydra-icq.c
-rw-r--r-- 1 nxpgsql  513  17806 2011-07-15 04:17 hydra-imap.c
-rw-r--r-- 1 nxpgsql  513   5990 2011-07-15 04:17 hydra-irc.c
-rw-r--r-- 1 nxpgsql  513  13425 2011-07-15 04:17 hydra-ldap.c
-rw-r--r-- 1 nxpgsql  513  38078 2011-07-15 04:17 hydra-logo.ico
-rw-r--r-- 1 nxpgsql  513     25 2011-07-15 04:17 hydra-logo.rc
-rw-r--r-- 1 nxpgsql  513  23398 2011-07-15 04:17 hydra-mod.c
-rw-r--r-- 1 nxpgsql  513   1914 2011-07-15 04:17 hydra-mod.h
-rw-r--r-- 1 nxpgsql  513   5625 2011-07-15 04:17 hydra-mssql.c
-rw-r--r-- 1 nxpgsql  513  11827 2011-07-15 04:17 hydra-mysql.c
-rw-r--r-- 1 nxpgsql  513   4929 2011-07-15 04:17 hydra-ncp.c
-rw-r--r-- 1 nxpgsql  513  13070 2011-07-15 04:17 hydra-nntp.c
-rw-r--r-- 1 nxpgsql  513   5473 2011-07-15 04:17 hydra-oracle.c
-rw-r--r-- 1 nxpgsql  513   8972 2011-07-15 04:17 hydra-oracle-listener.c
-rw-r--r-- 1 nxpgsql  513   4347 2011-07-15 04:17 hydra-oracle-sid.c
-rw-r--r-- 1 nxpgsql  513   6195 2011-07-15 04:17 hydra-pcanywhere.c
-rw-r--r-- 1 nxpgsql  513   5131 2011-07-15 04:17 hydra-pcnfs.c
-rw-r--r-- 1 nxpgsql  513  16287 2011-07-15 04:17 hydra-pop3.c
-rw-r--r-- 1 nxpgsql  513   3067 2011-07-15 04:17 hydra-postgres.c
-rw-r--r-- 1 nxpgsql  513   2574 2011-07-15 04:17 hydra-rexec.c
-rw-r--r-- 1 nxpgsql  513   3812 2011-07-15 04:17 hydra-rlogin.c
-rw-r--r-- 1 nxpgsql  513   2946 2011-07-15 04:17 hydra-rsh.c
-rw-r--r-- 1 nxpgsql  513   3363 2011-07-15 04:17 hydra-sapr3.c
-rw-r--r-- 1 nxpgsql  513   8279 2011-07-15 04:17 hydra-sip.c
-rw-r--r-- 1 nxpgsql  513  47810 2011-07-15 04:17 hydra-smb.c
-rw-r--r-- 1 nxpgsql  513  12393 2011-07-15 04:17 hydra-smtp.c
-rw-r--r-- 1 nxpgsql  513   6569 2011-07-15 04:17 hydra-smtp-enum.c
-rw-r--r-- 1 nxpgsql  513   5479 2011-07-15 04:17 hydra-snmp.c
-rw-r--r-- 1 nxpgsql  513   4054 2011-07-15 04:17 hydra-socks5.c
-rw-r--r-- 1 nxpgsql  513   4386 2011-07-15 04:17 hydra-ssh.c
-rw-r--r-- 1 nxpgsql  513   5041 2011-07-15 04:17 hydra-svn.c
-rw-r--r-- 1 nxpgsql  513   3328 2011-07-15 04:17 hydra-teamspeak.c
-rw-r--r-- 1 nxpgsql  513   6373 2011-07-15 04:17 hydra-telnet.c
-rw-r--r-- 1 nxpgsql  513   4300 2011-07-15 04:17 hydra-vmauthd.c
-rw-r--r-- 1 nxpgsql  513   6794 2011-07-15 04:17 hydra-vnc.c
-rw-r--r-- 1 nxpgsql  513  16531 2011-07-15 04:17 hydra-xmpp.c
-rw-r--r-- 1 nxpgsql  513     59 2011-07-15 04:17 INSTALL
-rw-r--r-- 1 nxpgsql  513  16964 2011-07-15 04:17 libpq-fe.h
-rw-r--r-- 1 nxpgsql  513  36015 2011-07-15 04:17 LICENSE
-rw-r--r-- 1 nxpgsql  513   8540 2011-07-15 04:17 LICENSE.OPENSSL
-rw-rw-r-- 1 root    root   3678 2011-07-25 20:51 Makefile
-rw-r--r-- 1 nxpgsql  513   3109 2011-07-15 04:17 Makefile.am
-rw-rw-r-- 1 root    root    528 2011-07-25 20:51 Makefile.in
-rw-r--r-- 1 nxpgsql  513     19 2011-07-15 04:17 Makefile.unix
-rw-r--r-- 1 nxpgsql  513  40651 2011-07-15 04:17 ntlm.c
-rw-r--r-- 1 nxpgsql  513   4406 2011-07-15 04:17 ntlm.h
-rw-r--r-- 1 nxpgsql  513   1722 2011-07-15 04:17 performance.h
-rw-r--r-- 1 nxpgsql  513   2021 2011-07-15 04:17 postgres_ext.h
-rw-r--r-- 1 nxpgsql  513   1541 2011-07-15 04:17 pw-inspector.1
-rw-r--r-- 1 nxpgsql  513   4631 2011-07-15 04:17 pw-inspector.c
-rw-r--r-- 1 nxpgsql  513  38078 2011-07-15 04:17 pw-inspector.ico
-rw-r--r-- 1 nxpgsql  513     27 2011-07-15 04:17 pw-inspector-logo.rc
-rw-r--r-- 1 nxpgsql  513  12072 2011-07-15 04:17 README
-rw-r--r-- 1 nxpgsql  513  21201 2011-07-15 04:17 sasl.c
-rw-r--r-- 1 nxpgsql  513   1300 2011-07-15 04:17 sasl.h
-rw-r--r-- 1 nxpgsql  513   1179 2011-07-15 04:17 xhydra.1
-rw-r--r-- 1 nxpgsql  513 218327 2011-07-15 04:17 xhydra.png
root@hostname:~/hydra/hydra-6.5-src# ./configure

Starting hydra auto configuration ...
Detected 64 Bit Linux OS

Checking for openssl (libssl, libcrypto, ssl.h, sha.h) ...
                                                       ... found
Checking for idn (libidn.so) ...
                             ... found
Checking for pcre (libpcre.so, pcre.h) ...
                                       ... found
Checking for Postgres (libpq.so, libpq-fe.h) ...
                                             ... found
Checking for SVN (libsvn_client-1 libapr-1.so libaprutil-1.so) ...
                                                               ... found
Checking for firebird (libfbclient.so) ...
                                       ... found
Checking for MYSQL client (libmysqlclient.so, math.h) ...
                                                      ... found
Checking for AFP (libafpclient.so) ...
                                   ... NOT found, module Apple Filing Protocol disabled - Apple sucks anyway
Checking for NCP (libncp.so / nwcalls.h) ...
                                         ... NOT found, module NCP disabled
Checking for SAP/R3 (librfc/saprfc.h) ...
                                      ... NOT found, module sapr3 disabled
Get it from http://www.sap.com/solutions/netweaver/linux/eval/index.asp
Checking for libssh (libssh/libssh.h) ...
                                      ... found
Checking for Oracle (libocci.so libclntsh.so / oci.h) ...
                                                      ... NOT found, module Oracle disabled
Checking for GUI req's (pkg-config, gtk+-2.0) ...
                                              ... found

Hydra will be installed into .../bin of: ~
  (change this by running ./configure --prefix=path)

Writing Makefile.in ...
now type "make"
root@hostname:~/hydra/hydra-6.5-src# apt-file search libafpclient.so
root@hostname:~/hydra/hydra-6.5-src# apt-file search libncp.so
libncp: /usr/lib/libncp.so
libncp: /usr/lib/libncp.so.2.3
libncp: /usr/lib/libncp.so.2.3.0
root@hostname:~/hydra/hydra-6.5-src# apt-file search nwcalls.h
libncp-dev: /usr/include/ncp/nwcalls.h
root@hostname:~/hydra/hydra-6.5-src# ainstall libncp-dev
Reading package lists... Done
Building dependency tree      
Reading state information... Done
The following NEW packages will be installed:
  libncp-dev
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 269 kB of archives.
After this operation, 995 kB of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com/ubuntu/ natty/universe libncp-dev amd64 2.2.6-8 [269 kB]
Fetched 269 kB in 2s (105 kB/s)     
Selecting previously deselected package libncp-dev.
(Reading database ... 313315 files and directories currently installed.)
Unpacking libncp-dev (from .../libncp-dev_2.2.6-8_amd64.deb) ...
Processing triggers for man-db ...
Setting up libncp-dev (2.2.6-8) ...
root@hostname:~/hydra/hydra-6.5-src# ./configure
Starting hydra auto configuration ...
Detected 64 Bit Linux OS

Checking for openssl (libssl, libcrypto, ssl.h, sha.h) ...
                                                       ... found
Checking for idn (libidn.so) ...
                             ... found
Checking for pcre (libpcre.so, pcre.h) ...
                                       ... found
Checking for Postgres (libpq.so, libpq-fe.h) ...
                                             ... found
Checking for SVN (libsvn_client-1 libapr-1.so libaprutil-1.so) ...
                                                               ... found
Checking for firebird (libfbclient.so) ...
                                       ... found
Checking for MYSQL client (libmysqlclient.so, math.h) ...
                                                      ... found
Checking for AFP (libafpclient.so) ...
                                   ... NOT found, module Apple Filing Protocol disabled - Apple sucks anyway
Checking for NCP (libncp.so / nwcalls.h) ...
                                         ... found
Checking for SAP/R3 (librfc/saprfc.h) ...
                                      ... NOT found, module sapr3 disabled
Get it from http://www.sap.com/solutions/netweaver/linux/eval/index.asp
Checking for libssh (libssh/libssh.h) ...
                                      ... found
Checking for Oracle (libocci.so libclntsh.so / oci.h) ...
                                                      ... NOT found, module Oracle disabled
Checking for GUI req's (pkg-config, gtk+-2.0) ...
                                              ... found

Hydra will be installed into .../bin of: ~
  (change this by running ./configure --prefix=path)

Writing Makefile.in ...
now type "make"
root@hostname:~/hydra/hydra-6.5-src# apt-file search saprfc.h
root@hostname:~/hydra/hydra-6.5-src# acache sapr3
root@hostname:~/hydra/hydra-6.5-src# acache sapr
root@hostname:~/hydra/hydra-6.5-src# apt-file search libocci.so
root@hostname:~/hydra/hydra-6.5-src# apt-file search libclntsh.so
root@hostname:~/hydra/hydra-6.5-src# apt-file search libclntsh.so
root@hostname:~/hydra/hydra-6.5-src#make && make install

Sunday, July 24, 2011

wreckergrep One-Liner

 find . -iname "<search_pattern>" -print | while read f; do grep -Ril <search_file_content> "$f"; done

OR

#!/bin/bash
# wreckergrep.sh
find . -iname "<search_pattern>" -print | while read f; do
  grep -Ril $1 "$f"
done




Okay,

Now save the file as wreckergrep.sh and change your permissions:
chmod 755 wreckergrep.sh

Use your new utility with the following syntax:

./wreckergrep.sh <search_file_pattern>

So, for example running the one-liner:
 find . -iname "*.py" -print | while read f; do grep -Ril http "$f"; done


Will return every python file containing the search_file_pattern "http"

Hopefully this helps ya out in a pinch ;)


Later skaterz ;)

Script that Rips the Largest Track from DVD and Encodes as AVI from the Command Line

Hello again folks!

Time to share an oldie but goodie - ripping movies from a DVD using Linux via the command line.  This is useful if you're tired of pointing and clicking around GUI rippers, you're working on DVD ripping automation, etc.

This script will grab the largest track from a DVD (i.e. the actual movie) and convert the track to AVI (MPEG-4):

#!/bin/bash
main_feature=`lsdvd | grep "Longest track" | awk '{print $3}'` # Choose the largest track for the main feature
out_file="/home/cerberus/Videos/$1.avi"
if [[ $1 != "" ]]; then
  mencoder dvd://$main_feature -nosub -noautosub -ovc lavc -lavcopts vcodec=mpeg4:vhq:vbitrate="1200" -vf scale -zoom -xy 720 -oac mp3lame -lameopts br=128 -alang en -o $out_file
else
  echo "./rip_dvd_2_avi.sh <name_of_dvd>"
  #echo "Available Tracks are: "
  #lsdvd
fi

Save the file as rip_dvd_2_avi.sh and change the permissions using the following command:

chmod 755 rip_dvd_2_avi.sh


Now, create a Videos folder in your home directory OR change the path of the out_file variable found on line 4 in the bash script above:

mkdir ~/Videos

and last but not least execute your super awesome script:

./rip_dvd_2_avi.sh TheNameofYourDVD

That's it.  Until next time peeps!

Sunday, June 19, 2011

Control the Window Geometry of Any Linux / BSD Graphical Application....

Super short and sweet post this time...

Did you know that you can can control the window geometry and placement of any graphical application in most, if not all, desktop environments/window managers, permitted an x window environment is available (e.g. Xorg)?

This is useful with machines when you notice the same graphical applications staying open.  Another benefit is that it provides the means to be more efficient when you can start to remember where specific windows are located at any given moment.  Here's the one liner -  feel free to use this code to automate your desktops into productive and friendly minions:


















Said one-liner:

$ wmctrl -l | grep -i konqueror | awk '{print $1}' | while read win_id; do transset-df -i $win_id 0.9; wmctrl -ir $win_id -e 0,0,1700,1200,185; done

Here's a quick explanation of the aforementioned one-liner (ensure konqueror is already running):

  1. "wmctrl -l" provides a list of every graphical window currently running.  
  2. "grep -i konqueror" looks for a case-insensitive window titled, "konqueror." 
  3. "awk '{print $1}'" only displays the first column of the "konqueror" line from stdout via "wmctrl -l."  The first column is the window id for Konqueror.
  4. "while read wind_id; do " read in the id column (first column) from "wmctrl -l"
  5. "transset-df -i $wind_id 0.9;" change translucency of window to 0.9. Love it.
  6. "wmctrl -ir $wind_id -e 0,0,1700,1200,185;" change the geometry (size) of the window and its placement (where the window will actually reside on the desktop)
  7. "done" all done ;)

Hope you find this useful!

adiĆ³s amigos!
  

If you enjoyed this post, send us = kudos = 
(Bitcoin Addr: 19n6q3GZfoM64oqv5HsDnhzqvcEvJUvmdx)

Control a Synergy Server and its Clients from One Server Script, One Keyboard, and One Mouse - the Easy Way

Today we're going to cover an amazing little utility that has made many-a-boxen here at the hang4r look like Tank's operator station from the movie, "The Matrix."




This little utility is known as synergy and is used for controlling multiple computers from one keyboard and mouse over any network.  For more information on installation/configuration, please visit here.

Unfortunately, synergy comes with one noticeable caveat - no network traffic encryptie supportie.  Guess we'll have to remedy that, won't we?

Now, there are plenty of blogs out there on the ol dub-dub-dub that describe how to enable network-based encryption for synergy using stunnel or openssh.  Unfortunately, they typically present this with a solution that requires a series of scripts that live on the synergy server (synergys) and the synergy client (synergyc).  If you're as serious about synergy as we are, you'll notice it gets a bit "twitchy" when you constantly find yourself having to disconnect/reconnect often...calling different scripts here and there, rubbish.  Time to change all that :)

Today, you'll have the opportunity to learn how to connect your synergy clients to a synergy server all sourcing from one synergy server.  This is all accomplished through our friend, OpenSSH and its reliable wingman, reverse tunneling.   

Again, this all in one, easy shell script connects synergy clients to the synergy server from...you got it, the synergy server.  That's right, no more annoying typing on this keyboard or that keyboard to get your synergy clients connected...clackity-click-clack.  We heart that idea almost as much as we heart lock picking as a past-time in the shop.  While you're thinking about lock picking in the shop, consider picking up this book...it's one of the better ones out there on lock picking:

















Our apologies for the digression - back to the regularly scheduled program...here we go:


STEP 1: Okay, first you must setup key-based authentication for OpenSSH so that your synergy server can authenticate with the synergy clients without requiring a person to actually type a password (or at least a moderately sophisticated zombie robot).

STEP 1.1: Run the following command from your synergy server:
$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/<user>/.ssh/id_rsa):<PRESS_ENTER>
Enter passphrase (empty for no passphrase):<LEAVE BLANK, PRESS_ENTER>
Enter same passphrase again:<LEAVE BLANK, PRESS_ENTER>
Your identification has been saved in /home/<user>/.ssh/id_rsa.
Your public key has been saved in /home/<user>/.ssh/id_rsa.pub.
The key fingerprint is:
cc:d9:cb:d8:cd:24:ad:87:41:1c:57:90:14:73:00:fb user@hostname
The key's random art image is:
+--[ RSA 2048]----+
|    ..+el...     |
|     . n...      |
|    .   o .      |
|     . + * .     |
|      N O p e    |
|         = O     |
|        . * +    |
|           .     |
|                 |
+-----------------+

STEP 1.2: Transfer the synergy server file, id_rsa.pub to your remote synergy client:
$ scp /home/<user>/.ssh/id_rsa.pub <user>@<remote synergy client>:/home/<user>/

STEP 1.3: SSH into your remote synergy client computer:
$ ssh <user>@<remote synergy client>
<user>@<remote synergy client> password: <TYPE PASSWORD>

STEP 1.4: Append the contents of id_rsa.pub to the authorized_keys file:
$ cat /home/<user>/id_rsa.pub >> /home/<user>/.ssh/authorized_keys

***At this point you should be able to authenticate to your remote synergy client from your synergy server machine.  Please note that you also must ssh from the synergy server as the synergy server user that possesses the id_rsa.pub file within their "/home/<user>/.ssh" directory.  Of course you ssh to the synergy client using the synergy client user that contains the authorized_keys file within their "/home/<user>/.ssh" directory.  So far, so good.

STEP 2: The script...now, here comes the beautiful part.  Create a file called onesyn.sh on your synergy server and paste the following:

#!/bin/bash
# onesyn.sh

# Start the synergy server daemon and sleep to ensure it's up
# prior to kicking off our uber-simple client initialization
synergys &
sleep 2

# now, reverse-ssh into synergy client using key-based auth
# and kick off synergy client over an encrypted network tunnel
ssh -R 127.0.0.1:24800:127.0.0.1:24800 <user>@<remote synergy client> "synergyc -f 127.0.0.1"

# end of script

That's it folks!  Simply save your file and make it executable by issuing the following command:

$ chmod 755 onesyn.sh

Have this script auto-run each time you authenticate with your favorite desktop environment (KDE, Gnome, etc.).  Better yet, use  your favorite window manager instead (OpenBox, FluxBox, FVWM, etc.) since desktop environments are made for people with an unhealthy amount of patience.

Logout, log back in, and enjoy your lavishly excessive array of flat-panel displays, crts, and computing devices all accessible and dominated from one keyboard and mouse!  Yes, it's even okay to sit back, raise your hands towards the back of your head, and totally bask in your amazing awesomeness ;)

Kickin ass n chewin bubble gum.  Later skaterz!

If you enjoyed this post, send us = kudos = 
(Bitcoin Addr: 19n6q3GZfoM64oqv5HsDnhzqvcEvJUvmdx)


quickiedisc.sh - An Oldie but a Goodie for Linux Burning

Copy->paste->save this into a file named quickiedisc.sh. 

#!/bin/bash
usage() {
   printf "*Usage: quickiedisc.sh [--copy --data --iso --rip] <\"file\">\n"
   printf " --copy: Copy CD or DVD utilizing one drive :)\n"
   printf " --data: Burn a specified file or folder to CD or DVD\n"
   printf " --iso : Burn an ISO file to CD or DVD\n"
   printf " --rip : Rip a CD or DVD\n"
   exit
}

if [[ $# != 2 ]]; then
   usage
fi

case $1 in
   "--copy" ) dd if=/dev/scd0 of=/tmp/quickie_tmp.iso;
              eject /dev/scd0;
              printf "Please insert blank disk.  Press any key to continue..."; read anykey;
              cdrecord -v speed=16 dev=ATA:1,0,0 /tmp/quickie_tmp.iso;
              rm /tmp/quickie_tmp.iso;;
   "--data" ) mkisofs -r -o "${2}.iso" "${2}";
              cdrecord -v speed=16 dev=ATA:1,0,0 "${2}.iso";
              #cdrecord -v speed=16 dev=ATAPI:0,0,0 "${2}.iso";
              rm ${2}.iso;;
   "--iso"  ) cdrecord -v speed=16 dev=/dev/scd0 "${2}";;
   "--rip"  ) dd if=/dev/scd0 of="${2}.iso";;
         *  ) printf "Invalid Flag.\n"; usage;;
esac
eject /dev/scd0
# End of script

Also, be sure you set permissions as executable:


$ chmod 755 quickiecd.sh

Enjoy, cheers!

If you enjoyed this post, send us = kudos = 
(Bitcoin Addr: 19n6q3GZfoM64oqv5HsDnhzqvcEvJUvmdx)


Saturday, June 18, 2011

monkeyrunner - Android Automation

Today, we're going to show you how simple it is to automate android events via the Android SDK with a tool known as, monkeyrunner.

The monkeyrunner tool provides an API for writing programs that control an Android device or emulator from outside of Android code (for more information, click here).  The interesting thing about monkeyrunner from our own experience is that if you run:

$ <android_sdk_path>/tools/monkeyrunner

with no parameters, you'll be presented with a wonderful Jython prompt...this means that possibilities are endless and limited only by one's imagination. :)



Now that the cogs are spinnin' and you can say to yourself, "this totally has potential" - let's dive right into automating some Android stuff!

Here's a python script that automates opening an android application, running various keypad events, and taking two screenshots for upload to the Android Developers Market.  Create a file called, monkeyrunner_job1.py and paste the following into the file (of course replacing the proper values of variable objects marked with the comment, "# INFO_NEEDED_ON_LINE_BELOW":

# Imports the monkeyrunner modules used by this program
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
import time
import sys

# Connects to the current device, returning a MonkeyDevice object
# INFO_NEEDED_ON_LINE_BELOW
device = MonkeyRunner.waitForConnection(600,'<adb device value taken from sdk command, "android_skd_path/adb devices">') # Wait 10 Minutes Until Things Start Exploding...

# Installs the Android package. Notice that this method returns a boolean, so you can test to see if the installation worked.
# INFO_NEEDED_ON_LINE_BELOW
install_status = device.installPackage('<apk_path>/app.apk')
print install_status
if install_status != True:
  print "Something went wrong with the installation!"
  sys.exit(1)

## sets a variable with the package's internal name
# INFO_NEEDED_ON_LINE_BELOW
package = 'com.yourmobileapp.prod.YourOwnAndroidApplication'

## sets a variable with the name of an Activity in the package
# INFO_NEEDED_ON_LINE_BELOW
activity = '.Yourmobileapp'

# sets the name of the component to start
runComponent = package + '/' + activity

# Runs the component
device.startActivity(component=runComponent)

time.sleep(60)
device.press('KEYCODE_DPAD_DOWN') # Press Down

# Takes a screenshot
result1 = None
while result1 == None:
  result1 = device.takeSnapshot()

print "Value of result1 Screenshot object"
print result1



# INFO_NEEDED_ON_LINE_BELOW
result1.writeToFile('./SB/screens/screen1.png','png')

# Press the Down Arrow and Long Press to Obtain Context Menu
time.sleep(3)
device.drag((150,300), (150,300), 10, 1) # Long Press
time.sleep(3)
device.press('KEYCODE_DPAD_DOWN') # Down
time.sleep(3)

# Take another Screenshot
result2 = None
while result2 == None:
  result2 = device.takeSnapshot()

print "Value of result2 Screenshot object"
print result2
result2.writeToFile('./SB/screens/screen2.png','png')


Save monkeyrunner_job1.py - now, to actually run it and see each item run line by line (great for debugging) execute the following command at a shell prompt:

$ <android_sdk_path>/tools/monkeyrunner <  monkeyrunner_job1.py

I hope you find this useful!

If you enjoyed this post, send us = kudos = 
(Bitcoin Addr: 19n6q3GZfoM64oqv5HsDnhzqvcEvJUvmdx)



For more information about writing Android applications in Java, check out this book on Amazon:



Cheers!

Tuesday, June 14, 2011

Productive Linux Aliases Initialized Following User Authentication

Sup Folks,

I wanted to take this opportunity to share some of my favorite Linux aliases used by many people in the community.  Some may believe that *nix aliases are the spawn del diablo...mostly because it's easy for aliases to get out of hand if typing descriptive, unique, and easy-to-remember aliases aren't your cup o' tea.

Aliases are really helpful if you find yourself typing long commands on a regular basis, kind of like this simple one-liner that displays the types of files located in the current working directory:


$ ls | while read f; do file $f; done

The small list of aliases found below certainly increase productivity because, well...less keys are required to be pressed on your happy hacker keyboard. 

Setting up aliases in the manner described below will have them initialized following user authentication into your favorite Linux distro (Some of the aliases below are specific to distros with apt available as the package manager):

1. Edit ~/.bashrc and add the following line at the very bottom of the file:


$ source /etc/profile.d/aliases.sh

Save your changes and exit.

2. Create /etc/profile.d/aliases.sh and add the following:

#!/bin/bash
alias acache="apt-cache search"
alias ainstall="apt-get install"
alias aremove="apt-get remove"
alias aupdate="apt-get update"
alias aupgrade="apt-get upgrade"
alias adupgrade="apt-get dist-upgrade"
alias cless="/usr/share/vim/vim72/macros/less.sh"
alias dadd="darcs add"
alias doupgrade="/usr/bin/do-release-upgrade -d"
alias dpull="darcs pull"
alias dpush="darcs push"
alias drecord="darcs record"
alias grep="grep --color=auto"
alias jgeminstall="jruby -S gem install"
alias kpid="kill -9"
alias kall="killall -9"
alias ls="ls --color=auto"
alias ll="ls -l --color=auto"
alias lh="ls -lh --color=auto"
alias netpain="netstat -pane | grep -e udp -e tcp | less"
alias prep="ps -ef | grep"
alias sup="sudo su -"
alias s_rhost="ssh <user>@<rhost>" # Replace <user> with remote ssh user and <rhost> with remote hostname of SSH server.  Replace the alias name with the same <rhost> hostname.

3. Setup executable permissions on /etc/profile.d/aliases.sh.  Not even sure this is necessary due to the way this file is executed from /etc/profile but I do it any way:

$ chmod 755 /etc/profile.d/aliases.sh


4. Log out and log back in...

That's it!

If you enjoyed this post, send us = kudos = 
(Bitcoin Addr: 19n6q3GZfoM64oqv5HsDnhzqvcEvJUvmdx)




For more info on UNIX and Linux system administration, check out this book:



If you have any other aliases that have personally helped you, feel free to post them as comments to help everyone else!

Lat3r sk4t3rz :p