2015/01/02

为反编译Android应用设置Linux环境

没有评论:
Linux environment setup

ubuntu 14.04 64-bit virtual machine on virtual box
1. shared folder:   in virtual box setting, create two shared folder “Documents”, “Downloads” on mac os, set full r/w rights and permanent. then in unbuntu’s mnt directory you will see “sf_Downloads” and “sf_Documents” ( with AdditionIn package installed ).
2. however, you may need to run “sudo adduser fanghui vboxsf” to add yourself to vboxsf group, and restart ubuntu guest.


android apktool
http://ibotpeaches.github.io/Apktool/install/
1. Check java 1.7 installed or not
       $java -version
       $sudo apt-get install default-jre  (or openjdk-7-jre)


2. Download Linux wrapper script (https://raw.githubusercontent.com/iBotPeaches/Apktool/master/scripts/linux/apktool,  Right click, Save Link As apktool)

3. Download apktool-2 (https://bitbucket.org/iBotPeaches/apktool/downloads, find newest here)

4. Make sure you have the 32bit libraries (ia32-libs) downloaded and installed by your linux package manager, if you are on a 64bit unix system.
(This helps provide support for the 32bit native binary aapt, which is required by apktool)

5. Rename downloaded jar to apktool.jar

6. Move both files (apktool.jar & apktool) to /usr/local/bin (root needed)
Make sure both files are executable (chmod +x)

7. Try running apktool via cli
   example:   $apktool d flappy-bird.apk
  will unzip the file structure
  find “Fake Flappy birds on Android” on http://androidmalwaredump.blogspot.sg/


dex2jar
   download dex2jar from http://sourceforge.net/projects/dex2jar/files/
   extract to a folder
        $unzip -x dex2jar-2.0.zip  -d /home/your_folder
   convert apk to jar file  ( you might need chmod +x d2j* )
        $sh /home/your_folder/dex2jar-2.0/d2j-dex2jar.sh  flappy_bird.apk


jd-gui
    download from jd.benow.ca
  it is a jar file “jd-gui-1.1.0.jar", so run with
     $java -jar jd-gui-1.1.0.jar
 a gui will pop up.

jad
jad is a decompiler tool similar to jd-gui, except command line.
download from http://varaneckas.com/jad/
somehow i cannot run jad 1.5.8e for linux on intel, so i choose jad 1.5.8e for linux (statically linked) instead.


boomerang (not mature)
download boomerang-linux-alpha-0.3 from http://boomerang.sourceforge.net/download.php
it requires libgc. when I try to run the program, I get this error:
./boomerang: error while loading shared libraries: libgc.so.1: cannot open shared object file: No such file or directory

You need to install libgc, something like

sudo apt-get install libgc1c2
sudo apt-get install libgc1c2:i386 
  (for 64-bit linux)

boomerang also requires libexpat1
sudo apt-get install libexpat1:i386

ok.

====
Note: run 32-bit executable on 64-bit linux

use “file file_name” to view exe type.

file-name: ELF 32-bit LSB  executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.8, not stripped


firstly install ia32-libs.
sudo apt-get install ia32-libs
or
sudo apt-get update
sudo apt-get install lib32z1 lib32ncurses5 lib32bz2-1.0

or
To run 32bit executable file in a 64 bit multi-arch Ubuntu system, you have to add i386 architecture and also you have to install libc6:i386,libncurses5:i386,libstdc++6:i386 these three library packages.
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386
sudo ./file-name

2014/12/01

Linux compiler warnings

没有评论:
When compiling C++ programs, gcc reports -Wwrite-strings warning.
xxx.cpp:344:5: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
Solution 1 (推荐):
     cast constant string from char * s = "constant string" to const char *s= "constant string".

Solution 2:
 you can also pass -Wno-write-strings to gcc which then suppresses this warning.

Solution 3:
#pragma GCC diagnostic ignored "-Wwrite-strings"    忽略警报
...
#pragma GCC diagnostic pop       重新打开警报


gcc reports -Wmultichar warning:
xxx.cpp:332:7: warning: multi-character character constant [-Wmultichar]
 #if (('1234' >> 24) == '1')     // little endian ?
       ^
这个是用宏判断机器是否little-endian/big-endian,一般主机都是little-endian.
Solution 1 (推荐):
Check endian-ness at run time:
 int IS_LITTLE_ENDIAN() {
  static const int NL_AT_END = 0x000A;
  return ((char*)(void*)&NL_AT_END)[0] == '\n';
 }

Solution 2:
pass -Wno-multichar  to gcc for suppressing this warning.

Further reading: http://zipcon.net/~swhite/docs/computers/languages/c_multi-char_const.html
 

2014/06/18

ODBC driver problem

没有评论:
2009年写的一个船舶碰撞模拟器最近要求再产生一些数据,于是重新拾掇了程序。发现连接的mdb文件数据库在windows 7 64-bit上有问题:

Microsoft ODBC Administrator: The setup routines for the Microsoft Access Driver (*.mdb, *.accdb) ODBC driver could not be found. Please reinstall the driver.

找出原因如下:

We have an excel sheet that runs a report and get it's data from a database. The database that it gets the data from was recently moved to a different shared instance. I am now having issues setting up a new connection to the shared instance that the database now resides on. When I try to go in to try to add an ODBC I only have an option to setup a SQL server connection (No option to setup an Excel Files ODBC). If I try to configure the existing Excel Files ODBC I get the error

"The setup routines for the Microsoft Excel Driver ODBC driver could not be found. Please re-install the driver."

Once I click "OK" on that error another one pops up saying "Errors found: The specified DSN contains an architecture mismatch between the driver an application."

The system is running Windows 7 Enterprise (x64), has 6GB of RAM, an Intel Xeon E5620 (2.4GHz) and the version of office is Office 2010 Pro.


解决办法:
在64位机器上直接使用odbc 32-bit程序。
Use odbcad32.exe under %WINDIR%\SYSWOW64, you will find all the 32bit drivers enumerated.  MS Access 32-bit ODBC driver is already shipped.

32-Bit Excel needs 32-Bit ODBC-Adminstrator odbcad32.exe which lives in C:\Windows\SysWOW64

64-Bit Excel needs 64-Bit ODBC-Adminstrator odbcad32.exe which lives in C:\Windows\System32



2014/04/09

OpenSSL HeartBleed 漏洞来势凶猛

没有评论:
最近透露出来的OpenSSL HeartBleed (心脏滴血)漏洞很厉害,yahoo.com 都被用来作为POC攻击的示范站点。不过发此文时yahoo似乎已修复, 但查询top 1000...网站确实还有不少中招。ssltest python script 轻易就可以搜到,就不放在此了,注意它们只是显示是否vulnerable,并没有显示message content,当然这也很简单。此时攻防双方应该是在分秒必争,我觉得一些搞bitcoin的一些网站真是应该小心了。。。

INSECURE - bitcurex.com:443 has the heartbeat extension enabled and is vulnerable
INSECURE - localbitcoins.com:443 has the heartbeat extension enabled and is vulnerable
INSECURE - vip.btcchina.com:443 has the heartbeat extension enabled and is vulnerable
INSECURE - www.bitfinex.com:443 has the heartbeat extension enabled and is vulnerable
INSECURE - www.bitgo.com:443 has the heartbeat extension enabled and is vulnerable
INSECURE - www.bitstamp.net:443 has the heartbeat extension enabled and is vulnerable
INSECURE - www.cryptsy.com:443 has the heartbeat extension enabled and is vulnerable
INSECURE - www.virwox.com:443 has the heartbeat extension enabled and is vulnerable



OpenSSL HeartBleed bug
http://heartbleed.com/

Online heartbleed test
http://possible.lv/tools/hb/
http://filippo.io/Heartbleed/
https://www.ssllabs.com/ssltest/



2014/04/08

Skype Silk 与Opus的关系

没有评论:
Skype自2009年1月以来一直采用自己的SILK音频编码解码器,但是从2012年起过渡到新的Opus标准。Opus标准已经获互联网工程任务组(IETF)批准,标准格式为RFC 6716。它 是一个有损声音编码的格式,适用于网络上的实时声音传输。Opus支持6kbps到510kbps的可变比特率。由于是一个开放格式,Opus在使用上没有任何专利限制。

Opus合并了Xiph.org的CELT低延时音频编解码器和Skype的SILK语音编解码器,专为互联网音频设计,可用于替代现有的私有音频编解码器,由 Xiph.Org、Mozilla、微软、Broadcom、Octasic和Google联合开发。


目前软件包版本是Opus v1.1
Skype Opus Codec