martes, 6 de abril de 2010

How to use ffmpeg to convert a video stream from avi to flv

This is not our usual kind of information but ... here comes an example for trancoding between avi and flv.


ffmpeg -i "e:\ejemplo_chulo.avi" -y -r 25 -b 650000 -f flv -vcodec flv -ab 128 -ar 44100 salidata.flv

For a complete list of video and audio qualities see this link

martes, 16 de marzo de 2010

Curl https client certificate negotiation

Just in case we need to perform continous testing against a https resource that requires certificate authentication:
curl --cert buenokpl.pem --key buenokpr.pem --pass fulano123 -k -v https://www.google.es

Reading socket identifier from proc fs

cd /proc//fd
ls -ltr|grep -i socket
fetch the socket id on the rigth side and do a netstat -ae|grep -i

miércoles, 10 de marzo de 2010

Getting server certificates with openssl

This recipe is very useful if you need to download the certificate from a server that uses ssl for connection encryption.
With your favorite openssl distribution just type:

openssl s_client -connect 172.16.1.42:22


CONNECTED(00000003)
depth=0 /C=ES/ST=Spain/L=madrid/O=xxx/OU=seguridad/CN=localhost
verify error:num=18:self signed certificate
verify return:1
depth=0 /C=ES/ST=Spain/L=madrid/O=xxx/OU=seguridad/CN=localhost
verify return:1
---
Certificate chain
0 s:/C=ES/ST=Spain/L=madrid/O=xxx/OU=seguridad/CN=localhost
i:/C=ES/ST=Spain/L=madrid/O=xxx/OU=seguridad/CN=localhost
---
Server certificate
-----BEGIN CERTIFICATE-----
MIIC/DCCAroCBEuLj7EwCwYHKoZIzjgEAwUAMGQxCzAJBgNVBAYTAkVTMQ4wDAYD
VQQIEwVTcGFpbjEPMA0GA1UEBxMGbWFkcmlkMQwwCgYDVQQKEwNzaWExEjAQBgNV
BAsTCXNlZ3VyaWRhZDESMBAGA1UEAxMJbG9jYWxob3N0MB4XDTEwMDMwMTA5NTgw
OVoXDTEwMDUzMDA5NTgwOVowZDELMAkGA1UEBhMCRVMxDjAMBgNVBAgTBVNwYWlu
MQ8wDQYDVQQHEwZtYWRyaWQxDDAKBgNVBAoTA3NpYTESMBAGA1UECxMJc2VndXJp
ZGFkMRIwEAYDVQQDEwlsb2NhbGhvc3QwggG3MIIBLAYHKoZIzjgEATCCAR8CgYEA
/X9TgR11EilS30qcLuzk5/YRt1I870QAwx4/gLZRJmlFXUAiUftZPY1Y+r/F9bow
9subVWzXgTuAHTRv8mZgt2uZUKWkn5/oBHsQIsJPu6nX/rfGG/g7V+fGqKYVDwT7
g/bTxR7DAjVUE1oWkTL2dfOuK2HXKu/yIgMZndFIAccCFQCXYFCPFSMLzLKSuYKi
64QL8Fgc9QKBgQD34aCF1ps93su8q1w2uFe5eZSvu/o66oL5V0wLPQeCZ1FZV466
1FlP5nEHEIGAtEkWcSPoTCgWE7fPCTKMyKbhPBZ6i1R8jSjgo64eK7OmdZFuo38L
+iE1YvH7YnoBJDvMpPG+qFGQiaiD3+Fa5Z8GkotmXoB7VSVkAUw7/s9JKgOBhAAC
gYB6L1euyIcyqIcnDqjNoVxTIbq+hXPGuV7E27j6PkXQdhboJJPvOrBnS7GbCMtP
65IbedsJm+raK5rfCzkUXvrg6/LNM9zs6BNBZBVLiyh2o2ueecGc6hBCUA2WMbGc
6QB3oBIfxAv++//1+knIL1+A26jrBU58AfnNpDK43T1coTALBgcqhkjOOAQDBQAD
LwAwLAIURZdToJ9MjzXze0oCgS280KwsunICFC1Crf4hj1kP7OdZhVXvlP4gCQi1
-----END CERTIFICATE-----
subject=/C=ES/ST=Spain/L=madrid/O=xxx/OU=seguridad/CN=localhost
issuer=/C=ES/ST=Spain/L=madrid/O=xxx/OU=seguridad/CN=localhost
---
Acceptable client certificate CA names
/C=ES/O=Recipes/CN=ca
---
SSL handshake has read 1315 bytes and written 288 bytes
---
New, TLSv1/SSLv3, Cipher is EDH-DSS-DES-CBC3-SHA
Server public key is 1024 bit
Compression: NONE
Expansion: NONE
SSL-Session:
Protocol : TLSv1
Cipher : EDH-DSS-DES-CBC3-SHA
Session-ID: 4B976688585F4BDA3C35765B4F2C6119F90064A77BFCC73D4C2E26A283864204
Session-ID-ctx:
Master-Key: D0D069F3AC2059DA628F55A2847A7EA9744AADBB62FA379D1D480832FB36330A560D93872F75CA340C999733EB0E2F45
Key-Arg : None
Start Time: 1268213384
Timeout : 300 (sec)
Verify return code: 18 (self signed certificate)
---
closed



jueves, 18 de febrero de 2010

lunes, 15 de febrero de 2010

Copy MBR from one disk to another

This command will do the trick:
dd if=/dev/sda of=/dev/sdb bs=512 count=1



Getting Virtualized!!!

I had been looking for a process where you could take an existing physical machine, and convert it into a new virtual one.
There are a few steeps that are needed in order to achive this goal:
- Define a virtualized hardware: CPU, Memory, IO, Networking.
- Export the data: this is the most critical process.
In order to get an vmkd file or vdi of an existing physical instalation consists in a few steps that i will explain here:
- First, boot the operating system with a live linux cd.
- Second, identify the partition or partitions involved in the recovery. For instance hd3
- Third, make a good use of dd like this one:
dd if=/dev/hdc of=/mnt/USB/diskImage/win2k3.img bs=1024
the partition will be dumped into a file.
- Fourth: qemu-img convert -f raw /mnt/USB/diskImage/w2k3.img -O vmdk /mnt/external/diskImage/w2k3.vmdk

VMware: Using player to install yor VM's

VMware player is almost a complete virtualization platform, the only thing that is missing to achive the full functuality of its big brother Workstation is the "Configuration Wizard".
I had found a website that allows you to define a vmx file (the configuration file) but i have found also a procedure to create your own.

The basics.

virtualHW.version
This parameter defines the version used. Defaults to 4

displayName
This parameter will be used in order to identify the virtual machine.

memsize
This parameter is obvious. Configures the amount of memory reserved for the vm.
defaults to Megabytes. Example 512


ideX:X.fileName
This parameter will be used in order to identify the disk . An example could look like this: "FREEDOS.vmdk"

ideX:X.present
Enables the availability of the disk to the vm. TRUE/FALSE

guestOS
The id of the operating system. See bellow in the Guest OS section list.
example winXPPro

Network
This section is a little bit more complicated. Each nic can have 3 status:
- bridget.
- hostOnly
- Internal Network.
Example :

ethernet0.present = "TRUE"
ethernet0.vnet = "VMnet0"
ethernet0.virtualDev = "vlance"


cdrom.

ide1:0.fileName = "E:\2k3-sp1-pebuilder313\pebuilder.iso"
ide1:0.deviceType = "cdrom-image"
ide1:0.startConnected = "TRUE"
ide1.1.present = "FALSE"



A more complex vmx file.

This example has been extracted from http://sanbarrow.com/vmxbuilder.html

###### stupid-long-name .vmx #################
######
###### use copy and paste
###### to export this file
######
#######################################
####### generated by Ullis VM builder #

####### Identity ######################
displayName = "stupid-long-name"

# Devices
config.version = "8"
virtualHW.version = "4"
memsize = "512"
numvcpus = "2"
guestOS = "winNetEnterprise"

####### ide-disks #####################
ide0.0.present = "FALSE"
ide0.1.present = "FALSE"
ide1:0.present = "TRUE"
ide1:0.fileName = "E:\2k3-sp1-pebuilder313\pebuilder.iso"
ide1:0.deviceType = "cdrom-image"
ide1:0.startConnected = "TRUE"
ide1.1.present = "FALSE"

####### scsi-controllers ##################
scsi0.present = "TRUE"
scsi0.virtualDev = "buslogic"
scsi1.present = "TRUE"
scsi1.virtualDev = "lsilogic"

####### scsi-disks #####################
scsi0:0.present = "FALSE"
scsi0:1.present = "FALSE"
scsi0:2.present = "FALSE"
scsi0:3.present = "FALSE"
scsi0:4.present = "FALSE"
scsi0:5.present = "FALSE"
scsi0:6.present = "FALSE"
scsi1:0.present = "FALSE"
scsi1:1.present = "FALSE"
scsi1:2.present = "FALSE"
scsi1:3.present = "FALSE"
scsi1:4.present = "FALSE"
scsi1:5.present = "FALSE"
scsi1:6.present = "FALSE"

####### nics ##########################
ethernet0.present = "TRUE"
ethernet0.vnet = "VMnet0"
ethernet0.virtualDev = "vlance"
ethernet1.present = "TRUE"
ethernet1.vnet = "VMnet1"
ethernet1.virtualDev = "vmXnet"
ethernet2.present = "TRUE"
ethernet2.vnet = "VMnet2"
ethernet2.virtualDev = "vlance"
ethernet3.present = "TRUE"
ethernet3.vnet = "VMnet3"
ethernet3.virtualDev = "vmXnet"

####### sound #########################
sound.present = "FALSE"

####### usb ###########################
usb.present = "FALSE"

####### floppies #######################
floppy0.present = "FALSE"
floppy0.startConnected = "FALSE"
floppy1.present = "FALSE"
floppy1.startConnected = "FALSE"

####### ports #########################
parallel0.present = "FALSE"
serial0.present = "FALSE"
serial1.present = "FALSE"

####### cluster-options ##################
####### skipping Cluster-options ###########



The Guest Os supported.
Bellow is the list of operating systems supported and the Id
Microsoft Windows, 32-bit

winVista = Windows Vista (experimental)
longhorn = Windows Longhorn (experimental)
winNetBusiness = Windows 2003 Small Business Server
winNetEnterprise = Windows 2003 Enterprise Server
winNetStandard = Windows 2003 Server
winNetWeb = Windows 2003 Web Server Edition
winXPPro = Windows XP Professional Edition
winXPHome = Windows XP Home Edition
win2000AdvServ = Windows 2000 Advanced Server
win2000Serv = Windows 2000 Server
win2000Pro = Windows 2000 Professional
winNT = Windows NT
winMe = Windows Me
win98 = Windows 98
win95 = Windows 95
win31 = Windows 3.1 / Windows 3.11
windows = Other Windows
Microsoft Windows, 64-bit

winVista-64 = Windows Vista x64 Edition (experimental)
longhorn-64 = Windows Longhorn x64 Edition (experimental)
winNetEnterprise-64 = Windows 2003 Enterprise Server x64 Edition
winNetStandard-64 = Windows 2003 Server x64 Edition
winXPPro-64 = Windows XP Professional x64 Edition
Linux, 32-bit

ubuntu = Ubuntu Linux
redhat = Red Hat Linux
rhel4 = Red Hat Enterprise Linux 4
rhel3 = Red Hat Enterprise Linux 3
rhel2 = Red Hat Enterprise Linux 2
suse = SuSE Linux
sles = SuSE Linux Enterprise Server
mandrake = Mandrake Linux
nld9 = Novell Linux Desktop 9
sjds = Sun Java Desktop System
turbolinux = Turbo Linux
other26xlinux = Other Linux on a 2.6.x kernel
other24xlinux = Other Linux on a 2.4.x kernel
linux = Other Linux
Linux, 64-bit

ubuntu-64 = Ubuntu Linux 64-bit
rhel4-64 = Red Hat Enterprise Linux 4 64-bit
rhel3-64 = Red Hat Enterprise Linux 3 64-bit
sles-64 = SuSE Linux Enterprise Server 64-bit
suse-64 = SuSE Linux 64-bit
other26xlinux-64 = Other Linux 2.6.x 64-bit
other24xlinux-64 = Other Linux 2.4.x 64-bit
otherlinux-64 = Other Linux 64-bit
Sun Microsystems Solaris

solaris10-64 = Solaris 10 64-bit
solaris10 = Solaris 10
solaris9 = Solaris 9
solaris8 = Solaris 8
solaris7 = Solaris 7
solaris6 = Solaris 6
solaris = Other Solaris
Novell Netware

netware6 = Netware 6.x
netware5 = Netware 5.x
netware4 = Netware 4.x
netware = Other Netware
FreeBSD

freeBSD-64 = FreeBSD 64-bit
freeBSD = FreeBSD
Apple Darwin

darwin = Apple Darwin (unsupported)
Other

other = Other OS
other-64 = Other 64-bit OS

viernes, 12 de febrero de 2010

VMDK file creation with QEMU

In order to get a vmdk file for VirtualBox or VMWare download the latest release of Qemu
and execute the following command:
>qemu-img.exe create -f vmdk WindowsXPPro.vmdk 2G for windows
>qemu-img create -f vmdk WindowsXPPro.vmdk 2G for linux

jueves, 11 de febrero de 2010

Ldap timestamp search

Hi there!!!
I had to produce an incremental ldif file from an ldap server. This file had to have all ldap entries modified from a certain date (for example 1st of Febrary 2010). But the issue was not as easy as it sounds, mainly because i had to guess what was the search string that provided a valid filter in order to get the desired results.
The format is as follows:
YYYYMMDDhhmmssZ
4 digit Year
2 digits Month
2 digits Day
2 digits hour
2 digits minute
2 digits second
End with "Z" char
Example:

ldapsearch -x -H ldaps://A.B.C.D:636 -D "cn=admin,o=demo" -W -b "ou=users,o=kasa" "modifyTimestamp>=20100201000000Z" >tst.ldif

I hope that it will be usefull for you.

martes, 2 de febrero de 2010

Multiple CPU top report

Many times i wanted to know what was the status of the system in terms of CPU usage. In the interactive mode just press the "1" key and on the top side of the report you would be able to see the status of every core you have on your system.
Regards...

lunes, 25 de enero de 2010

Changing ip address with IP command

Hi there!!!
It's been a while since I don't practice my blogging skills , in part because I've been in holidays, and in part because i've been too lazy :D. No, seriously, i've been working on a project with a very tight deadline and i've been so exhausted that when i come back home i only wanted to have a break of computers.
Well, lets talk about our today's topic. Network configuration has been centralized with ip commands and today we will deal with network device management.
What we previously perform with ifconfig up and ifconfig down today can be run with:

ip link set dev up

ip link set dev eth0 up

or
ip link set dev down

ip link set dev eth0 down

I will try to improve this entry with many other options like ipaddress and things like that.

Cheers and have a Zen day!!!

jueves, 7 de enero de 2010

Changing the UUID of a disk for a virtual machine on Sun Virtual Box

Hello everyone!!!
First of all, I want to wish to every person who visits this site a happy new year.
2009 has been a very difficult year for a lot of people i know (even myself) , and i hope 2010 to be much better with a lot of new challenges, experiences, etc...
Back to our blog, i want to share a tip that will allow us to duplicate the UUID of a disk.
This is very helpful when you need to reuse a clean operating system installation on several vms on the same machine.
By default Virtual Box will complain with a message saying that
"hard disk with UUID {55b773b8-cbcb-42ea-9a44-1368b3XXXX} or with the same properties is already registered" failing to load the disk.
In order to avoid this, just type :
VBoxManage internalcommands setvdiuuid |diskname.vdi|
and a new UUID will be generated and assigned.
Ciaooo!