“OOPS… Why do my tabs look like french fries?”: Turn Off Tab Highlighting

Posted in Uncategorized with tags , on May 27, 2012 by ShellAdept

Hello,

I’m still not sure what key combination I hit to start this undesirable behavior, but sometimes VIM will start highlighting your tabs.  This makes code more difficult to read for me, as I my eyes are drawn toward this bar-graph of color!  But I don’t want to turn off colored characters, because I do find this feature useful.  To do this, comment out ‘set hlsearch’ in the following lines of /etc/vimrc like so:

" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
syntax on
"  set hlsearch
endif

Yay! Have fun coding =]

Monitor Active TCP Connections

Posted in bash, Linux, scripting, Uncategorized with tags on October 1, 2011 by ShellAdept

root@localhost:~# watch "netstat | grep -i -e "Foreign" -e "Internet" -e "tcp""

The ‘watch’ command will continuously execute the subsequent command (for more complex commands, as above, the entire set of commands should be enclosed in double-quotes.). By default, ‘watch’ executes every 2 seconds.

The ‘netstat’ command displays network connections (among other things–for more information refer to the Man page.). In this example, grep is used to filter out non-TCP connections.

The ‘grep’ command is used to print lines which match a desired pattern. In this example, ‘-i’ is used to ignore case, and ‘-e’ is used to print multiple patterns. Lines containing ‘tcp’, ‘Foreign’, and ‘Internet’ are printed (the latter two are used to maintain the first two lines of netstat output).

I hope somebody finds this useful. If anyone has suggestions for improvement or spots an error on my part, please feel to share. I welcome feedback!

Can’t Connect to Database in Backtrack 5

Posted in Linux, Metasploit, Pentesting on July 30, 2011 by ShellAdept

I’ve found that after diconnecting from the default ‘msf3’ database created by Metasploit in a standard Backtrack 5 installation, I can’t reconnect.  I also am unable to create and connect to a new database.  So after some search-engine-fu, I found the following work-around:

root@bt:~# apt-get install postgresql libpq-dev
root@bt:~# su postgres -c psql #su as 'postgres', run command 'psql'
could not change directory to "/root"
psql (8.4.8)
Type "help" for help.

postgres=# ALTER USER postgres WITH PASSWORD 'myPass';
ALTER ROLE
postgres=# \q
could not save history to file "/home/postgres/.psql_history": No such file or directory
root@bt:~# sudo passwd -d postgres
passwd: password expiry information changed.
root@bt:~# sudo su postgres -c passwd
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

I originally found this solution posted by ‘ZeroCold’ at “http://zerocold.co.uk/?p=819”

Basically, you install ‘postgresql’ and ‘libpq-dev’, then change the password for user ‘postgres’ both in postgresql and the underlying OS. Keep in mind that you use whatever password you gave the user from within ‘psql’ when connecting to your Metasploit database (not ‘passwd’).

When you are ready to connect to a new or existing database, execute:
db_connect postgres:myPass@127.0.0.1/myDatabaseName

I have also found that a standard Backtrack 5 installation has issues with Metasploit’s msfconsole connecting to databases when the the absolute path (‘/pentest/exploits/framework3/msfconsole’) is used. When the console is launched with ‘msfconsole’ (no absolute path) the problem does not exist.

EDIT–
Poster abdisamad recently pointed out that there is a far simpler solution to this problem. Simply read the contents of /opt/framework3/config/database.yml to find the default information required to connect to the supplied msf3 database. It should look something like this:
db_connect msf3:thePassword@127.0.0.1:7175/msf3
Thanks for the feedback!

find all files containing string [of type .rb] recursively

Posted in Uncategorized on July 28, 2011 by ShellAdept

find / -type f -name “*.rb” -exec grep -il “myString” {} \; #semicolon is important
#Also, yes, there is an annoying space between the right-most curly-brace and backslash…

Gnome 3 on Fedora 15 Broke After an Update!? Don’t Panic.

Posted in Linux with tags on June 11, 2011 by ShellAdept

If you installed a new kernel, its likely that your Gnome 3 shell broke and Fedora 15 is using Fallback Mode.  Fear not!  This seems to be a problem with the Virtualbox Guest Additions having issues with the new kernel.  All you have to do to fix this is re-install the guest additions AFTER you’ve updated the kernel.  That should restore your VM’s Gnome 3 shell.

I will do tests to verify that this is the correct explanation for the issue, but I can certainly vouch for the validity of the fix.

Gnome 3 on Fedora 15 Guest (Virtualbox 4.0.8)

Posted in Linux on May 28, 2011 by ShellAdept

NOTE: Edits incoming–

Gnome 3 has failed to load...

After some trial and tribulation, I’ve got the Gnome 3 Shell working on a Fedora 15 virtual machine. This ‘guide’ ONLY works with Virtualbox 4.0.8+. Sorry its so rough–I just put it together in a few minutes. I’ll probably clean it up later, perhaps with screenshots!
First install Fedora 15; then ensure you have patched it completely. Make sure 3D Acceleration is ENABLED, as it likely is not by default (it wasn’t for me…).

Enable 3d Acceleration


This is changed via the Oracle VM Virtualbox Manager. I also gave 128 MB of Video Memory to the guest VM, though this is likely overkill. Turn on your shiny new VM.
Inside your VM, install your appropriate kernel-headers, kernel-devel, and the gcc compiler (g++ should also work in place of gcc). If you are using the 2.6.38.6-27 kernel on a 64-bit system, your install process will look something like this:

[root@localhost ~]$ yum install kernel-headers-2.6.38.6-27.fc15.x86_64
#installs kernel-headers--your headers' version may be different
[root@localhost ~]$ yum install kernel-devel-2.6.38.6-27.fc15.x86_64
#installs kernel-devel--your kernel version may be different
[root@localhost ~]$ yum install gcc
#installs gcc compiler--NECESSARY for installing guest additions

Now that you’ve installed the above, you are ready to install Virtualbox Guest Additions. Select ‘Devices>Install Guest Additions’. Now, from within your Fedora 15 VM, run the VBoxLinuxAdditions.run file. You can access this file by navigating to the newly found CD under ‘/media/’. If you’re using the command line, you’ll use ‘./VBoxLinuxAdditions.run’. Or you can double-click the file of the same name in the graphical interface. The install should be more or less automatic at this point.

Now restart your VM. Gnome 3 should automatically start and waste countless hours of your productive life :]

If this doesn’t work the first time, don’t fret. I had to change the order up to get it to work for me, and if your Guest Additions don’t install properly the first time, you may have to try again. Remember: snapshots are your friend!

EDIT (6.4.2011): If you are using a 32-bit system with the same kernel, use kernel-devel-2.6.38.6-27.fc15.i686 and kernel-headers-2.6.38.6-27.fc15.i686.

Eww Math: Trigonometry

Posted in Uncategorized on January 16, 2011 by ShellAdept

A circle is equal to 360 degrees.  A circle is also equal to 2π radians.

One radian is equal to 360/2π, or approximately 57.296 degrees.

To convert from radians to degrees, multiply by 180/π.

To convert from degrees to radians, multiply by π/180.

    Fun with Python

    Posted in python, scripting on November 13, 2010 by ShellAdept

    #This article should see extensive expansion in the future. Till then, don’t expect much organization…

    To launch a Windows application (specifically calc.exe) using Python:

    >>> import os
    >>> os.startfile (“calc”)

    The word between quotes should contain the process name you wish to launch. For completionists, calc.exe works too…

    To list files in a particular directory:
    >>> import os
    >>> sweetPath=”C:\\temp_path”#’sweetPath’ is a variable name, clever at that–
    >>> dirList=os.listdir(sweetPath)
    >>> for k in dirList:
    … print k#make sure you tab this line

    aFile
    anotherFile
    yetAnotherFile
    etc.txt

    Hex Instruction Dictionary (x86)

    Posted in assembly, programming on November 9, 2010 by ShellAdept

    /*Incomplete listing of Intel x86 instructions’ hex values;  enjoy them, as it took me quite a while to decipher by comparing a hex dump of a binary with the original assembly.*/
    push BYTE    ==    ‘6a’
    push BYTE 112    ==    ‘6a 70’

    mov BYTE al    ==    ‘b0’
    mov BYTE bl    ==    ‘b3’
    mov BYTE cl    ==    ‘b1’
    mov BYTE dl    ==    ‘b2’

    mov BYTE al, 10    ==    ‘b0 0a’
    mov BYTE bl, 10 == ‘b3 0a’
    mov BYTE cl, 10 == ‘b1 0a’
    mov BYTE dl, 10 == ‘b2 0a’

    mov [ebx+7], al == ’88 43 07′
    mov [ebx+8], ebx == ’89 5b 08′
    mov [ebx+12],eax == ’89 43 0c’

    int        ==    ‘cd’
    int 0x80    ==    ‘cd 80′

    push        ==    ’68’
    push 0x2f552f2f    ==    ’68 2f 2f 55 2f’
    push WORD    ==    ’66’
    push WORD bx    ==    ’66 53′
    push esi    ==    ’56’
    push ecx    ==    ’51’
    push edx    ==    ’52’
    push ebx    ==    ’53’

    xor        ==    ’31’
    xor eax, eax    ==    ’31 c0′
    xor ebx, ebx    ==    ’31 db’
    xor ecx, ecx    ==    ’31 c9′
    xor edx, edx == ’31 d2′

    mov        ==     ’89’
    mov ebx, eax    ==    ’89 c3′
    mov ecx, esp    ==    ’89 e1′
    mov ebx, esp    ==    ’89 e3′
    mov edx, esp    ==    ’89 e2′

    pop eax        ==    ’58’ #66 58?
    pop ebx == ‘5b’ #66 5b?
    pop ecx        ==    ’59’ #66 59?
    pop edx == ‘5a’ #66 5a?

    cdq        ==    ’99’

    inc ebx        ==    ’43’

    xchg esi, eax    ==    ’96’
    xchg eax, ebx    ==    ’93’

    dec eax == ’48’ #66 48?
    dec ebx == ‘4b’ #66 4b?
    dec ecx        ==    ’49’ #66 49?
    dec edx == ‘4a’ #66 4a?

    jns        ==    ’79’
    call == ‘e8’
    short jump == ‘eb’ #eb f9?
    return == ‘c9’

    lea ecx, [ebx+8] == ‘8d 4b 08’
    lea edx, [ebx+12] == ‘8d 53 0c’

    NOTE: Though most of this dictionary has been created through trial and error using nasm, ndisasm, and hexdump, Jon Erickson’s “Hacking: The Art of Exploitation” was incredibly helpful with sample code and accompanying byte code. I highly recommend the book those interested in computer security.

    Assembly Compilation with NASM

    Posted in assembly, nasm, programming on October 23, 2010 by ShellAdept

    //Stand in post–more to follow

    ‘nasm’ is an assembly compiler available on your favorite linux distro.  It is easily installed with your respective package manager (yum, apt-get, etc.).  Assembly programs are suffixed with ‘.s’ or ‘.asm’.  To compile your example.asm, type:

    nasm -f elf example.asm

    In this case, nasm invokes the compiler, ‘-f’ specifies the output file format (here elf is used, which is short for elf32–most users of 32 bit linux systems will probably be fine using this format.  For a complete list of formats available, type ‘nasm -hf’ in your terminal.)  And example.asm, of course, is your source file.

    Next, type:

    ld example.0

    This invokes the GNU linker–for more information on this, refer to the man page for ld.  Keep in mind that nasm and ld are not the same.  Now you can type ./a.out and your program should run.

    If ld is complaining of incompatibility with your x64 system:

    ld: i386 architecture of input file ‘example.o’ is incompatible with i386:x86-64 output

    Try compiling with the following command:

    nasm -f elf64 example.asm

    at this point, ld example.o should work.  Congratulations!

    /*Please take this article with a grain of salt.  I do my best to present only accurate information, but it is entirely possible that I may post something inaccurate from time to time.  If you find errors in this article, please let me know and I’ll update it accordingly.  We are all here to learn and constructive criticism is very welcome!  Or, if you found it helpful, let me know–that would make my day!*/

    Design a site like this with WordPress.com
    Get started