lost and found ( for me ? )

Linux Mint 14 64bit : change java version from open java to Oracle Java



mint ~ # tail -1 /etc/lsb-release
DISTRIB_DESCRIPTION="Linux Mint 14 Nadia"
mint ~ # uname -ri
3.5.0-26-generic x86_64


install JDK from Oracle’s site.
I downloaded  jdk-7u17 for Linux 64bit.
mint hattori # ls *.tar.gz
jdk-7u17-linux-x64.tar.gz

make a directory for JDK 1.7.0
mint jvm # mkdir /usr/lib/jvm/jdk1.7.0-oracle

extract jdk and move files under /usr/lib/jvm/jdk1.7.0-oracle directory.
mint hattori # tar xzvf jdk-7u17-linux-x64.tar.gz
mint hattori # mv ./jdk1.7.0_17 /usr/lib/jvm/jdk1.7.0-oracle

change java version. select oracle java
mint hattori # update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.7.0-oracle/jdk1.7.0_17/bin/java" 1

mint hattori # update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.7.0-oracle/jdk1.7.0_17/bin/javac" 1

mint hattori # update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jdk1.7.0-oracle/jdk1.7.0_17/bin/javaws" 1


mint hattori # update-alternatives --config java
There are 2 choices for the alternative java (providing /usr/bin/java).

 Selection    Path                                               Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java      1071      auto mode
 1            /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java      1071      manual mode
 2            /usr/lib/jvm/jdk1.7.0-oracle/jdk1.7.0_17/bin/java   1         manual mode

Press enter to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/lib/jvm/jdk1.7.0-oracle/jdk1.7.0_17/bin/java to provide /usr/bin/java (java) in manual mode
mint hattori #

mint ~ # update-alternatives --config javaws
There are 3 choices for the alternative javaws (providing /usr/bin/javaws).

 Selection    Path                                                 Priority   Status
------------------------------------------------------------
 0            /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/javaws      1071      auto mode
 1            /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/javaws      1061      manual mode
 2            /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/javaws      1071      manual mode
* 3            /usr/lib/jvm/jdk1.7.0-oracle/jdk1.7.0_17/bin/javaws   1         manual mode

Press enter to keep the current choice[*], or type selection number: ^C
mint ~ # update-alternatives --config javac  
There are 2 choices for the alternative javac (providing /usr/bin/javac).

 Selection    Path                                                Priority   Status
------------------------------------------------------------
 0            /usr/lib/jvm/java-7-openjdk-amd64/bin/javac          1071      auto mode
 1            /usr/lib/jvm/java-7-openjdk-amd64/bin/javac          1071      manual mode
* 2            /usr/lib/jvm/jdk1.7.0-oracle/jdk1.7.0_17/bin/javac   1         manual mode

Press enter to keep the current choice[*], or type selection number: 2

mint ~ # update-alternatives --config javaws
There are 3 choices for the alternative javaws (providing /usr/bin/javaws).

 Selection    Path                                                 Priority   Status
------------------------------------------------------------
 0            /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/javaws      1071      auto mode
 1            /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/javaws      1061      manual mode
 2            /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/javaws      1071      manual mode
* 3            /usr/lib/jvm/jdk1.7.0-oracle/jdk1.7.0_17/bin/javaws   1         manual mode
l
Press enter to keep the current choice[*], or type selection number: 3
mint ~ #

confirm java version
mint hattori # java -version
java version "1.7.0_17"
Java(TM) SE Runtime Environment (build 1.7.0_17-b02)
Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)

install ratproxy on Linux Mint14


about ratproxy

https://code.google.com/p/ratproxys
In short, ratproxy is passive web application security assessment tool

[ install ratproxy ]

You can install ratproxy via apt-get.
# apt-get install -y  ratproxy

start ratproxy
# ratproxy -v tmp_logs -w log.txt -d com -p 8080 -lfscm

launch browser and then configure proxy as 127.0.0.1:8080 and access to *.com sites.
after browsing , close the browser and then stop ratproxy

summary logs are in the log.txt and detailed logs are in *.trace file.
# head -1 log.txt
0|1|HTTP errors|-|503|989|text/html|text/html|iso-8859-1|tmp_logs/515254c8-7ffa.trace


# ls tmp_logs/*
tmp_logs/515253d9-7bc2.trace  tmp_logs/515253f3-7cb5.trace
tmp_logs/515253da-7bdd.trace  tmp_logs/515253f3-7cb7.trace

make a report file.
# ratproxy-report log.txt > report.html

view report.html

to output more detailed info , run ratproxy like this:
# ratproxy -v tmp_logs -w log.txt -d com -p 8080 -lextiscgjm

TCP session hijack : sessionlist


about sessionlist


I was able to compile sessionlist on Fedora 18. I , however , can not compilse that on ubuntu 12.04..
Here are logs including trial and error.

[ install sessionlist on Fedora 18 ( success ) ]

 999  git clone https://github.com/iamrage/sessionlist.git
1000  cd sessionlist/
1006  yum install -y libpcap-devel
1007  make

[root@f18 sessionlist]# locate libpcap.so
/usr/lib64/libpcap.so.1
/usr/lib64/libpcap.so.1.3.0
[root@f18 sessionlist]# locate libncurses
/usr/lib64/libncurses.so
/usr/lib64/libncurses.so.5
/usr/lib64/libncurses.so.5.9
/usr/lib64/libncursesw.so
/usr/lib64/libncursesw.so.5
/usr/lib64/libncursesw.so.5.9
[root@f18 sessionlist]# locate libpthread.so
/usr/lib64/libpthread.so
/usr/lib64/libpthread.so.0

usage
./sessionlist [eth number] [port number]
[root@f18 sessionlist]# ./sessionlist p10p1 80

***************************************************
sessionlist v1.0
***************************************************
c0ded by rage
***************************************************
Current hijacked sessions: 1 out of 7 tracked sessions

Found data for Host:  ad.jp.doubleclick.net
Found data for Host:  fls-fe.amazon.co.jp



if sessionlist can hijack TCP sessions , logs will be outputted in sessions.txt file.
[root@f18 sessionlist]# tail -f sessions.txt

Session 0 of 5 - IP: 192.168.11.100 IP: 176.32.120.142 - payload elements: 2
Host:  www.amazon.co.jp
user-agent:  Mozilla/5.0 (X11; Linux x86_64; rv:19.0) Gecko/20100101 Firefox/19.0
cookie:  x-wl-uid=1mAKbfgI6NBpx
<snip>


[ install sessionlist on ubuntu 12.04 ( fail ! ) ]

root@ubuntu1204-vm1:~# git clone https://github.com/iamrage/sessionlist.git
root@ubuntu1204-vm1:~# cd sessionlist/

error
root@ubuntu1204-vm1:~/sessionlist# make
g++ -march=native -O2 -pipe main.cpp sessionlist.cpp -lpcap -lpthread -lncurses -o sessionlist && strip sessionlist
In file included from main.h:25:0,
                from main.cpp:21:
sessionlist.h:24:18: fatal error: pcap.h: No such file or directory
compilation terminated.
In file included from sessionlist.cpp:21:0:
sessionlist.h:24:18: fatal error: pcap.h: No such file or directory
compilation terminated.
make: *** [all] Error 1

# apt-get install libpcap-dev

another error
root@ubuntu1204-vm1:~/sessionlist# make
g++ -march=native -O2 -pipe main.cpp sessionlist.cpp -lpcap -lpthread -lncurses -o sessionlist && strip sessionlist
In file included from main.h:25:0,
                from main.cpp:21:
sessionlist.h:37:21: fatal error: ncurses.h: No such file or directory
compilation terminated.
In file included from sessionlist.cpp:21:0:
sessionlist.h:37:21: fatal error: ncurses.h: No such file or directory
compilation terminated.

install
root@ubuntu1204-vm1:~/sessionlist# sudo apt-get install libncurses5-dev -y

try again
root@ubuntu1204-vm1:~/sessionlist# make
g++ -march=native -O2 -pipe main.cpp sessionlist.cpp -lpcap -lpthread -lncurses -o sessionlist && strip sessionlist
In file included from sessionlist.h:27:0,
                from main.h:25,
                from main.cpp:21:
headers.h:25:2: warning: ‘typedef’ was ignored in this declaration [enabled by default]
headers.h:42:2: warning: ‘typedef’ was ignored in this declaration [enabled by default]
headers.h:68:1: warning: ‘typedef’ was ignored in this declaration [enabled by default]
In file included from main.h:25:0,
                from main.cpp:21:
sessionlist.h:76:1: warning: ‘typedef’ was ignored in this declaration [enabled by default]
In file included from sessionlist.h:27:0,
                from sessionlist.cpp:21:
headers.h:25:2: warning: ‘typedef’ was ignored in this declaration [enabled by default]
headers.h:42:2: warning: ‘typedef’ was ignored in this declaration [enabled by default]
headers.h:68:1: warning: ‘typedef’ was ignored in this declaration [enabled by default]
In file included from sessionlist.cpp:21:0:
sessionlist.h:76:1: warning: ‘typedef’ was ignored in this declaration [enabled by default]
sessionlist.cpp: In function ‘void displayUsableSessionInfo()’:
sessionlist.cpp:394:167: warning: format ‘%i’ expects argument of type ‘int’, but argument 8 has type ‘std::list<unsigned char*>::size_type {aka long unsigned int}’ [-Wformat]
sessionlist.cpp:394:167: warning: format ‘%i’ expects argument of type ‘int’, but argument 8 has type ‘std::list<unsigned char*>::size_type {aka long unsigned int}’ [-Wformat]
sessionlist.cpp: In function ‘bool hasUsableSessionInfo(std::list<SESSION_INFO>::iterator, char*, char*, char*)’:
sessionlist.cpp:439:60: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
sessionlist.cpp:449:71: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
sessionlist.cpp: In function ‘void displayUsableSessionInfo()’:
sessionlist.cpp:419:27: warning: ignoring return value of ‘int system(const char*)’, declared with attribute warn_unused_result [-Wunused-result]
root@ubuntu1204-vm1:~/sessionlist# echo $?
0

root@ubuntu1204-vm1:~/sessionlist# ./sessionlist
/*
sessionlist v1.0
by rage
rage@0xrage.com
*/
Usage:
./sessionlist [interface] [port]- port is optional and defaults to 80. simple eh?

Seen  from README file , libpcap.so.1 , libncurses.so and libpthread.so are required to compile sessionlist.
Dependencies
------------

libpcap.so.1
libncurses.so.5
libpthread.so.0

So ensure you have these first.

nnn , core dump..
root@ubuntu1204-vm1:~/sessionlist# ./sessionlist eth0 80
/*
sessionlist v1.0
by rage
rage@0xrage.com
*/
Illegal instruction (core dumped)

In case of Fedora 18 , libpcap version is 1.3.
root@ubuntu1204-vm1:~/sessionlist# locate libpcap.so
/usr/lib/x86_64-linux-gnu/libpcap.so.0.8
/usr/lib/x86_64-linux-gnu/libpcap.so.1.1.1
root@ubuntu1204-vm1:~/sessionlist# locate libncurses.so
/lib/x86_64-linux-gnu/libncurses.so.5
/lib/x86_64-linux-gnu/libncurses.so.5.9
root@ubuntu1204-vm1:~/sessionlist# locate libpthread.so
/lib/x86_64-linux-gnu/libpthread.so.0

install backtrack linux 5 r3 within KVM


KVM host

[root@f18 ~]# libvirtd --version
libvirtd (libvirt) 1.0.3
[root@f18 ~]# qemu-kvm --version
QEMU emulator version 1.4.0, Copyright (c) 2003-2008 Fabrice Bellard
[root@f18 ~]# cat /etc/fedora-release
Fedora release 18 (Spherical Cow)

after I completed installing bt5 within KVM , I faced the following error.

error : no suitable mode found
error : unknown command ‘terminal’
vga=791 is deprecated.


To solve this , it seems that we may solve this by switching video model to cirrus.
So I tried to switch video model to cirrus via virt-manager , I faced another error.
XML error: ram attribute only supported for type of qxl

It was caused by the following bug.

Bug 920549 - error shows when changing video from qxl to other models

To solve this issue , edit the the xml file via “virsh edit” command.

virsh edit <VM name>

edit the following line:

form
<model type='qxl' ram='65536' vram='65536' heads='1'/>

to
<model type='cirrus' vram='65536' heads='1'/>

after switching video mode to cirrus , I am able to boot the BT5R3 within KVM successfully.

install ovirt-node within KVM


on the KVM host.

enable netsted on kvm_intel ( or kvm_amd )
# cat /sys/module/kvm_intel/parameters/nested
Y

download ovort-node iso file.
ovirt-node-iso-2.6.1-20120228.fc18.iso


Here’s overt-node VM’s xml file.
CPU parameters would differ from what type of CPU you are using.
virsh # dumpxml overt-node-1
<domain type='kvm' id='6'>
 <name>ovirt-node-1</name>
 <uuid>65647276-4fb5-9618-6fe8-5eab743ea473</uuid>
 <memory unit='KiB'>1048576</memory>
 <currentMemory unit='KiB'>1048576</currentMemory>
 <vcpu placement='static'>1</vcpu>
 <os>
   <type arch='x86_64' machine='pc-1.2'>hvm</type>
   <boot dev='cdrom'/>
   <boot dev='hd'/>
 </os>
 <features>
   <acpi/>
   <apic/>
   <pae/>
 </features>
 <cpu mode='custom' match='exact'>
   <model fallback='allow'>Westmere</model>
   <vendor>Intel</vendor>
   <feature policy='require' name='tm2'/>
   <feature policy='require' name='est'/>
   <feature policy='require' name='vmx'/>
   <feature policy='require' name='ds'/>
   <feature policy='require' name='smx'/>
   <feature policy='require' name='ss'/>
   <feature policy='require' name='vme'/>
   <feature policy='require' name='dtes64'/>
   <feature policy='require' name='rdtscp'/>
   <feature policy='require' name='ht'/>
   <feature policy='require' name='dca'/>
   <feature policy='require' name='pbe'/>
   <feature policy='require' name='tm'/>
   <feature policy='require' name='pdcm'/>
   <feature policy='require' name='pdpe1gb'/>
   <feature policy='require' name='ds_cpl'/>
   <feature policy='require' name='pclmuldq'/>
   <feature policy='require' name='xtpr'/>
   <feature policy='require' name='acpi'/>
   <feature policy='require' name='monitor'/>
 </cpu>
 <clock offset='utc'/>
 <on_poweroff>destroy</on_poweroff>
 <on_reboot>destroy</on_reboot>
 <on_crash>destroy</on_crash>
 <devices>
   <emulator>/usr/bin/kvm</emulator>
   <disk type='file' device='disk'>
     <driver name='qemu' type='raw'/>
     <source file='/var/lib/libvirt/images/ovirt-node-1.img'/>
     <target dev='vda' bus='virtio'/>
     <alias name='virtio-disk0'/>
     <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
   </disk>
   <disk type='file' device='cdrom'>
     <driver name='qemu' type='raw'/>
     <source file='/home/hattori/ISO_files/ovirt-node-iso-2.6.1-20120228.fc18.iso'/>
     <target dev='hdc' bus='ide'/>
     <readonly/>
     <alias name='ide0-1-0'/>
     <address type='drive' controller='0' bus='1' target='0' unit='0'/>
   </disk>
   <controller type='usb' index='0'>
     <alias name='usb0'/>
     <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
   </controller>
   <controller type='ide' index='0'>
     <alias name='ide0'/>
     <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
   </controller>
   <interface type='bridge'>
     <mac address='52:54:00:3b:bb:65'/>
     <source bridge='br0'/>
     <target dev='vnet1'/>
     <model type='rtl8139'/>
     <alias name='net0'/>
     <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
   </interface>
   <serial type='pty'>
     <source path='/dev/pts/9'/>
     <target port='0'/>
     <alias name='serial0'/>
   </serial>
   <console type='pty' tty='/dev/pts/9'>
     <source path='/dev/pts/9'/>
     <target type='serial' port='0'/>
     <alias name='serial0'/>
   </console>
   <input type='tablet' bus='usb'>
     <alias name='input0'/>
   </input>
   <input type='mouse' bus='ps2'/>
   <graphics type='vnc' port='5902' autoport='yes' listen='0.0.0.0'>
     <listen type='address' address='0.0.0.0'/>
   </graphics>
   <video>
     <model type='cirrus' vram='9216' heads='1'/>
     <alias name='video0'/>
     <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
   </video>
   <memballoon model='virtio'>
     <alias name='balloon0'/>
     <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
   </memballoon>
 </devices>
 <seclabel type='none'/>
</domain>

virsh #

install ovort-node.




after log into overt-node.