Thursday, April 7, 2016

Extracting files from windows executables (.exe) in linux

I am trying to extract firmimg.d7 from the iDRAC firmware exe file, to be used in a drac update using the drac web interface.

The first thing to do is to strip any prepended data (e.g. a SFX stub) from the archive, using a tool called zip. You can install this tool in centos by running yum install zip.

$ file iDRAC-with-Lifecycle-Controller_Firmware_JHF76_WN64_2.30.30.30_A00.EXE
iDRAC-with-Lifecycle-Controller_Firmware_JHF76_WN64_2.30.30.30_A00.EXE: PE32+ executable for MS Windows (GUI) Mono/.Net assembly

$ zip -J iDRAC-with-Lifecycle-Controller_Firmware_JHF76_WN64_2.30.30.30_A00.EXE

$ file iDRAC-with-Lifecycle-Controller_Firmware_JHF76_WN64_2.30.30.30_A00.EXE
iDRAC-with-Lifecycle-Controller_Firmware_JHF76_WN64_2.30.30.30_A00.EXE: Zip archive data, at least v1.0 to extract

Once the file has been shown as zip archive, the normal unzip program can be used to extract it

$ unzip iDRAC-with-Lifecycle-Controller_Firmware_JHF76_WN64_2.30.30.30_A00.EXE
Archive:  iDRAC-with-Lifecycle-Controller_Firmware_JHF76_WN64_2.30.30.30_A00.EXE
 extracting: bmcexe.bat
 extracting: bmcfexe.bat
  inflating: bmcfw64.exe
  inflating: bmcfwu.cfg
 extracting: bmcinv.bat
  inflating: DellSPMsg.dll
  inflating: dupgenexec.dll
  inflating: dupgeninv.dll
  inflating: dupvalid.dll
  inflating: getSystemId.exe
   creating: hapi/
  inflating: hapi/dcdbas32.cat
  inflating: hapi/dcdbas32.inf
  inflating: hapi/dcdbas32.sys
  inflating: hapi/dcdbas64.cat
  inflating: hapi/dcdbas64.inf
  inflating: hapi/dcdbas64.sys
 extracting: hapi/dcdipm64.sys
  inflating: hapi/dchapi32.dll
  inflating: hapi/dchapi64.dll
  inflating: hapi/dchbas32.dll
  inflating: hapi/dchbas64.dll
  inflating: hapi/dchcfg32.exe
  inflating: hapi/dchcfg64.exe
  inflating: hapi/dchcfl32.dll
  inflating: hapi/dchcfl64.dll
  inflating: hapi/dchesm32.dll
  inflating: hapi/dchipm32.dll
  inflating: hapi/dchipm64.dll
  inflating: hapi/dchtvm32.dll
  inflating: hapi/dciwds32.exe
  inflating: hapi/dcmdev32.exe
  inflating: hapi/dcmdev64.exe
  inflating: hapi/dcwipm32.dll
  inflating: hapi/dcwipm64.dll
  inflating: hapi/hapint.exe
  inflating: hapi/hapint64.exe
  inflating: hapi/omsacntl.exe
  inflating: hapinst.bat
  inflating: package.xml
   creating: payload/
  inflating: payload/firmimg.d7
  inflating: PIEConfig.xml
  inflating: PIEInfo.txt
  inflating: spconfig.xml
  inflating: spsetup.exe
  inflating: winhapi.ini

Now, the firmimg.d7 is ready to be used.

Wednesday, March 30, 2016

How to determine your proxy ip address and port using curl

This is very easy, what you have to do is use curl to access any site, and curl will let you know what is the proxy address if you have not put in your authentication details. See below example:

foobar@ubuntu-vm:~$ curl www.google.com -IL
HTTP/1.1 302 authenticationrequired
Date: Tue, 26 Jan 2016 06:46:15 GMT
Location: http://10.155.120.23:9090/mwg-internal/de5fs23hu73ds/plugin?target=Auth&reason=Auth&ClientID=2297288988&ttl=600&url=aHR0cDovL3d3dy5nb29nbGUuY29tLw==&rnd=1453790775
Connection: Keep-Alive
Content-Type: text/html
Cache-Control: no-cache
HTTP/1.1 401 authenticationrequired
Date: Tue, 26 Jan 2016 06:46:15 GMT
Connection: Keep-Alive
Content-Type: text/html
Cache-Control: no-cache
WWW-Authenticate: NTLM
WWW-Authenticate: Basic realm="MY COMPANY WEB GATEWAY"

You can see from above that my proxy ip address is 10.155.120.23, and my proxy port is 9090.

Monday, February 15, 2016

How to free reserved space on ext2/3/4 partitions

Linux by default, set aside around 5% of the total space in a partition for the root user and system service. For systems partition like /, this does make sense, since you won't be able to login if your / is full, but for other partitions, it does not seems that the reserve will help in any way.

You can find how much is being set as reserved by running:

$ sudo tune2fs -l /dev/sda1 | grep 'Reserved block count'
Reserved block count:     27709

So, for ext3/4 partitions, you can reclaim that reserve space by setting the reserve count to 0:
$ sudo tune2fs -m 0 /dev/sda1

Reserved block count will be 0% after the above command
$ sudo tune2fs -l /dev/sda1 | grep -i 'Reserved block count'
Reserved block count:     0

You can now fully enjoy the maximum space available for your partition.