Splitting a file in Linux, combining it on Windows

First lets check the md5sum:

#md5sum android-studio-bundle-162.4069837-windows.exe
0a8d2931afab56d407f4eb0ef7e54486  android-studio-bundle-162.4069837-windows.exe

Cut in into pieces:

split -b 100m android-studio-bundle-162.4069837-windows.exe

It gives pieces named xaa .. xat

I download it on Windows, combine them:

copy /b x*.* out.exe

Check the integrity:

CertUtil -hashfile out.exe MD5
MD5 hash of file out.exe:
0a 8d 29 31 af ab 56 d4 07 f4 eb 0e f7 e5 44 86
CertUtil: -hashfile command completed successfully.

You can see that the MD5 matches, so it has been transferred successfully.
I needed to do this because after transferring the huge 1.88 GB file, it failed to install while meant it was damaged while being downloaded. This way, if one of the pieces was transferred incorrectly, I could just redownload that alone.


You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.

Install Adobe Acrobat on Linux

You can install older version.

sudo add-apt-repository "deb http://archive.canonical.com/ precise partner"
sudo apt-get update
sudo apt install adobereader-enu

After properly installing Adobe Reader, don’t forget to remove the Canonical Partners repository for Precise:

sudo add-apt-repository -r "deb http://archive.canonical.com/ precise partner"

You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.

Browse a remote folder visually in Linux (ssh)

In Windows, you need to resort to other programs like WinSCP or Filezilla to visually browse ssh shares. In Linux, file managers natively support this.

First add your ssh key to the agent:

ssh-add ~/.ssh/mykey_openssh.pvt

Next, for convenience, create a config file so you can use aliases to connect.
Eg: To connect to 35.180.101.49 as root, we will use the alias ovh. So config file looks like this:

Host ovh
     Hostname 35.180.101.49
     User root
     Port 22

Now open a file manager, and in the address bar type this:

sftp://ovh4

It will momentarily show the root directory of the remote server. You can now edit remote scripts on your favorite locally installed IDEs. Enjoy!
Thunar seems slow for this. Nemo is perfect.


You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.

Extract icon from exe file in Linux

wrestool -o . -x filename.exe

You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.

Cut videos in Linux with avidemux

avidemux is a program that offers a GUI to cut videos on Linux. To install it, you need to either have the readymade .deb for your distro of Ubuntu, or compile it from source yourself. This post tells you how to compile and install avidemux for Ubuntu 16.10 (and other versions)

You need to first compile and install avidemux:

Download it from here, extract it.

tar xf avidemux_2.6.12.tar.gz
cd avidemux_2.6.12

Install all dependencies:

sudo apt-get install gcc g++ make cmake pkg-config libpng12-dev fakeroot yasm libsqlite3-dev  build-essential qttools5-dev-tools qtbase5-dev libaften-dev libmp3lame-dev libx264-dev  libfaad-dev libfaac-dev libqt4-dev

Compile and install:

bash bootStrap.bash --deb

Now install the compiled debs:

sudo dpkg -i debs/*deb

You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.

Decompiling and recompiling an apk in Linux using apktool (Tested on Ubuntu 16.04 and Android L on One Plus One)

Install apktool first:
Get it from http://ibotpeaches.github.io/Apktool/
Download latest apktool from here.

cd ~/
mkdir apktool
wget https://raw.githubusercontent.com/iBotPeaches/Apktool/master/scripts/linux/apktool
wget https://bitbucket.org/iBotPeaches/apktool/downloads/apktool_2.1.1.jar
mv apktool_2.1.1.jar apktool.jar
chmod +x apktool*
sudo mv apktool* /usr/local/bin/

You’ve now installed apktool.

Create a temp directory for apktool, and get your apk file.
Get your apk file via adb/from the connected phone via a file manager:

adb shell
cp /data/app/com.poke.media.pokemon/base.apk /sdcard/
adb pull /sdcard/base.apk 

Now, decompile it:

apktool d base.apk

The directory base will contain the decompiled files.

After working on it and making the necessary modifications, you need to install it after recompiling it:
apktool b base
adb install ./base/dist/base.apk

There will be an error because you havent signed it yet.

$ adb install ./new/dist/base.apk
5527 KB/s (18972821 bytes in 3.352s)
	pkg: /data/local/tmp/base.apk
Failure [INSTALL_PARSE_FAILED_NO_CERTIFICATES]

Signing recompiled apk files:
You need either the signtool that comes with java development kit (jdk)
Install jdk:

sudo apt-get install openjdk-9-jdk

If it has failed dependencies, like it did when I installed it on Ubuntu 16.04, try:

sudo aptitude install openjdk-9-jdk

jarsigner and keytool reqiured for signing will be installed by java jdk to the PATH. So, just do:

keytool -genkey -v -keystore my-release-key.keystore -alias mykey1 -keyalg RSA -keysize 2048 -validity 10000
Enter keystore password:  
Re-enter new password: 
What is your first and last name?
  [Unknown]:  Joel
What is the name of your organizational unit?
  [Unknown]:  None
What is the name of your organization?
  [Unknown]:  Somewhere
What is the name of your City or Locality?
  [Unknown]:  Trivandrum
What is the name of your State or Province?
  [Unknown]:  Kerala
What is the two-letter country code for this unit?
  [Unknown]:  IN
Is CN=Joel, OU=None, O=Somewhere, L=Trivandrum, ST=Kerala, C=IN correct?
  [no]:  yes

Generating 2,048 bit RSA key pair and self-signed certificate (SHA256withRSA) with a validity of 10,000 days
	for: CN=Joel, OU=None, O=Somewhere, L=Trivandrum, ST=Kerala, C=IN
Enter key password for <alias_name>
	(RETURN if same as keystore password):  
[Storing my-release-key.keystore]
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore ./new/dist/base.apk mykey1

Now install the apk:

adb install ./new/dist/base.apk
3863 KB/s (19077789 bytes in 4.821s)
	pkg: /data/local/tmp/base.apk
Success

You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.

Linux server hardening

Part 1: Audit and Scanner tools:
Lynis:
Download from https://cisofy.com/download/lynis/

Extract and run it:

wget https://cisofy.com/files/lynis-2.2.0.tar.gz
tar xf lynis-2.2.0.tar.gz
sudo chown -R 0:0 lynis
cd lynix
sudo ./lynis audit system

You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.

Extract icon files from exe files on Linux

sudo apt-get install icoutils
wrestool -x -t 14 source.exe > output.ico

You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.
Creating a bootable USB installer for Windows 10, 8.1 or 7

Creating a bootable USB installer for Windows 10, 8.1 or 7

The newest and most powerful kid on the block is Rufus, an excellent utility that cames in both Installable and Portable versions. It has a lot of options for creating an installable USB, and works for Windows and Linux.

MWSnap007 2015-08-28, 18_49_21


You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.

Find the type of file system, in Linux

Try the following:

#blkid -o value -s TYPE /dev/sda1
ext4

Or, for mounted partitions:

df -T
Filesystem     Type     1K-blocks     Used Available Use% Mounted on
rootfs         rootfs    20026236 20009848         0 100% /
/dev/root      ext4      20026236 20009848         0 100% /
devtmpfs       devtmpfs   1010720        0   1010720   0% /dev
tmpfs          tmpfs       202252      212    202040   1% /run
tmpfs          tmpfs         5120        0      5120   0% /run/lock
tmpfs          tmpfs       509140        0    509140   0% /dev/shm
/dev/sda2      ext4     459913320    71736 436456292   1% /home
 

You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.