Dec 29, 2015

Random 'fortune' + random 'cowsay'

/usr/games/fortune -s | /usr/games/cowsay -f `ls -1 /usr/share/cowsay/cows/ | sort -R | head -1` -n

Sep 29, 2015

Demonstrate all the 'cowsay'

for f in /usr/share/cowsay/cows/*; do cowsay -f "${f:23:-4}" "${f:23:-4}"; done

Jun 29, 2015

Oneplus-One and ADB USB Driver

Manually install Android ADB USB Driver:

  • Install Android SDK;
  • Then, select "Extras->Google USB Driver", and enable the checkbox;
  • Start Device Manager;
  • Browse to "Other devices", and right-click on "Android phones", then Update Driver Software;
  • Select "Browse my computer for driver software";
  • Select "Let me pick from a list of device drivers on my computer"; 
  • Select "Show All Devices";
  • Press the "Have Disk" button;
  • Enter the path to the Google USB driver. 
  • Normally it is located in the following directory:
  • C:\Program Files (x86)\Android\android-sdk\extras\google\usb_driver
  • C:\Users\Administrator\AppData\Local\Android\sdk\extras\google\usb_driver
  • Select "Android ADB Interface" from the list of device types;
  • Confirm the installation again by pressing "Install";
  • When the installation is done, press "Close".
Install OnePlus One USB Drivers on Windows:
  • Install the latest Samsung drivers: SAMSUNG USB Driver v1.5.33.0;
  • Install it like normal applications and restart your computer so that the drivers get installed correctly;
  • After that connect your OnePlus One to your computer.
  • Navigate to the Device Manager;
  • Find the Android device, and select Update Driver Software.
  • Select Browse my computer for driver software;
  • Select Let me pick from a list of device drivers on my computer;
  • Select ADB Interface from the list;
  • Select SAMSUNG Android ADB Interface (this is a signed driver); 
  • If you get a warning, select Yes to continue;
  • Done!

May 28, 2015

Power لُلُصّبُلُلصّبُررً ॣ ॣh ॣ ॣ 冗

Hi iPhone user, can you read the post title?

Send the following text to iPhone user and cause iMessage (notification) crashes:
Power لُلُصّبُلُلصّبُررً ॣ ॣh ॣ ॣ 冗
It crashed the iWatch too.

http://www.reddit.com/r/iphone/comments/37eaxs/um_can_someone_explain_this_phenomenon/

May 19, 2015

Unicode Character at console (using python)

Have Unicode fun at the console with:
$ python -c 'for c in range(0x1F410, 0x1F4f0): print (r"\U%08x"%c).decode("unicode-escape"),'

Unicode at console

May 18, 2015

webmap 0.2

Here is a script that helps to summarize an URL or a list of URLs to find the real servers. It follows those 301, 302, 303, or 200 with meta refresh, eliminates any 401, 402, 403, or 404 pages.

Below is the script:
#!/usr/bin/python
import sys, argparseimport httplib
import urllib2, cookielib, ConfigParser, osfrom re import searchimport refrom urllib2 import Request, urlopen, URLError, HTTPErrorimport socket
desc='To get the REAL URL from FQDN or list of FQDN.'vers='%(prog)s 0.2'debug=1finallist = []
def web_check_on (host, uri):    server = 'http://' + host    headers = {'User-Agent' : 'RedTeam (Jet)'}    req = Request(server, None, headers)
    try:      response = urlopen(req)    except HTTPError as e:                      #print 'The server couldn\'t fulfill the request.'      return "[FAILED."+str(e.code)+"] "+server #print 'Error code: ', e.code    except URLError as e:      if hasattr(e, 'reason'): #print 'We failed to reach a server.'          return "[FAILED]"    #print 'Reason: ', e.reason      elif hasattr(e, 'code'):     #print 'The server couldn\'t fulfill the request.'          return "[FAILED]"+e.code #print 'Error code: ', e.code    else: # everything is fine      final_server = response.geturl()      response.close()       return final_server      
def getipaddrs(hostname):    result = socket.getaddrinfo(hostname, None, 0, socket.SOCK_STREAM)    return [x[4][0] for x in result]
def net_check_on(hostname):    try:      hostips =  getipaddrs(hostname)    except socket.gaierror, e:      return "[FAILED.dns]"
    tcpport = 80    for hostip in hostips:      sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)      sock.settimeout(0.2)      port = sock.connect_ex((hostip, tcpport))      if port == 0:        return hostip # return the 1st IP for web_check_on        return "[FAILED.tcpport] " + ','.join(hostips)      def check_unique(seq):    seen = set()    seen_add = seen.add    return [ x for x in seq if not (x in seen or seen_add(x)) ]
if __name__ == "__main__":    #parser = argparse.ArgumentParser(description=desc, version=vers)    parser = argparse.ArgumentParser(description=desc)
    group1 = parser.add_argument_group('Input FQDN (compulsory)')    mgroup = group1.add_mutually_exclusive_group(required=True)    mgroup.add_argument('-d', dest='fqdn', help='FQDN')    mgroup.add_argument('-f', dest='ifile', help='Input file with list of FQDN')
    group2 = parser.add_argument_group('Input URI (optional)')    group2.add_argument('-p', action='store', dest='uri', default='/', help='wwwroot path. [/]')    group2.add_argument('-u', action='store_true', dest='uniqueonly', default=True, help='Print summary that shows unique URL only in x/y/z format (x=unique, y=connected, z=total).')    group2.add_argument('-D', action='store_true', dest='debug', default=False, help='Debug mode.')    group2.add_argument('--version', action='version', version='%(prog)s 1.0')
    args = parser.parse_args()
    debug = args.debug    host = args.fqdn    uri = args.uri
    if args.fqdn:      fullurl = '"' + host + uri +'"'      realserver = web_check_on(host, uri)      if debug:          print fullurl, realserver      else:          print realserver
    if args.ifile:      num = 0      with open(args.ifile, 'r') as f:        lines = [line.rstrip('\n') for line in f] # strip newline char        for line in lines:          num = num + 1          #print line          #(httpcode, realserver) = checking_on(line, uri)          #(httpcode, realserver) = web_check_on(line, uri)          line2 = net_check_on(line)          if "FAILED" not in line2:            realserver = web_check_on(line, uri)            finallist.append(realserver)          else:             realserver = ""          if debug:            print line + uri + " [" + line2 + "] ", realserver          #else:          #  print realserver
      if args.uniqueonly:        finallist2 = check_unique(finallist)        print '\n====='        print '\n'.join(finallist2)        print '----' + str(len(finallist2)) + '/' + str(len(finallist)) + '/' + str(num) + '----'



Apr 30, 2015

Simple Python cmdline argument handling

In Python, there are optparse module and its newer version, the argparse module, to build powerful solutions for command line interfaces.

Here is another simpler way to do the similar way, that handle the argument directly mapping to function arguments.

Below is the script:
#!/usr/bin/python
import sys
def do(x, y, z='zd'):  print 'x:', x  print 'y:', y  print 'z:', z
if __name__ == '__main__':  # Map command line arguments to function arguments.  do(*sys.argv[1:])

Let's pass in with 3 arguments:
$ ./do.py a b cx: ay: bz: c
Let's pass in with 2 arguments:
$ ./do.py a bx: ay: bz: zd
Let's pass in with 4 arguments:
$ ./do.py a b c dTraceback (most recent call last):  File "./do.py", line 12, in <module>    do(*sys.argv[1:])TypeError: do() takes at most 3 arguments (4 given)[1]    23517 exit 1     ./do.py a b c d
Let's pass in with 1 arguments:
$ ./do.py aTraceback (most recent call last):  File "./do.py", line 12, in <module>    do(*sys.argv[1:])TypeError: do() takes at least 2 arguments (1 given)[1]    23536 exit 1     ./do.py a

Apr 1, 2015

It's....

"It's done." - developer
"It's secure". - vendor
"It's deployed." - admin
...
"It's 0wn3d." - #hacker