Wednesday, February 6, 2013

pcap file format



http://wiki.wireshark.org/Development/LibpcapFileFormat#File_Format

패킷 헤더의 구조를 알면 패킷을 분석할 때 유용하다. 잘 알아둘 필요가 있다. wireshark에서 제공하는 문서를 잘 이해해 두기 바란다~

The Libpcap's format is following:

Global header | Packet Header | Packet Data | Packet Header | Packet Data | ...


# Global header has the following structure:


typedef struct pcap_hdr_s {
        guint32 magic_number;   /* magic number */
        guint16 version_major;  /* major version number */
        guint16 version_minor;  /* minor version number */
        gint32  thiszone;       /* GMT to local correction */
        guint32 sigfigs;        /* accuracy of timestamps */
        guint32 snaplen;        /* max length of captured packets, in octets */
        guint32 network;        /* data link type */
} pcap_hdr_t;


# Record (Packet) Header has the following structure:

typedef struct pcaprec_hdr_s {
        guint32 ts_sec;         /* timestamp seconds */
        guint32 ts_usec;        /* timestamp microseconds */
        guint32 incl_len;       /* number of octets of packet saved in file */
        guint32 orig_len;       /* actual length of packet */
} pcaprec_hdr_t;

Monday, February 4, 2013

install cx_Oracle on Ubuntu 12.04 or Windows


#1 Windows + cx_Oracle


1) download the Oracle instant client
http://www.oracle.com/technetwork/topics/winsoft-085727.html

2) place it on some directory.

3) Add the directory path to your PATH environment variable

4) run the following code to test

import cx_Oracle
conn = cx_Oracle.connect(ID/PW@DB.com)


#2 Ubuntu 12.04 + cx_Oracle
http://rahadianokta.wordpress.com/2012/09/15/oracle-instant-client-python-cx_oracle-ubuntu-server-12-04/

1) download the Oracle instant client
http://www.oracle.com/technetwork/topics/linuxsoft-082809.html

2) unzip to your lib path
 /usr/local/lib/

3) soft link libclntsh.so.11.1 to libclntsh.so and libocci.so.11.1 to libocci.so


4) add Oracle instant client path to ld.so.conf.d


 # ldconfig

5) edit your system environment variable (/etc/environment)




Finally~~ yeah~


Practical man-in-the-middle attack on pip


I got an interesting article that warns installing packages using pip
in an untrusted environment

You can  intercept and manipulate packages downloaded by PyPi
using the below python code

https://gist.github.com/4698537

yeah~ poc time~

Proof Of Concept

1. run a proxy to see all HTTP traffic through the proxy
2. redirect traffic over your local machine
3. intercepts all traffic
4. use the python script to manipulate downloads by PyPi

Wednesday, January 30, 2013

Oracle Tips


#1 list all the tables in a database

-> select * from tab;

#2 check oracle charset

-> select userenv('LANGUAGE') from dual;

#3 sysdate
 select   XXX    from   YYY
    where Time >= sysdate- INTERVAL '12' hour

#4 to_date
select *  from YYY where Time  >=  to_date('01-02-2013','dd-mm-yyyy');

#5 list all columns

SELECT *
FROM ALL_TAB_COLUMNS
WHERE TABLE_NAME IN (
  SELECT TABLE_NAME
  FROM ALL_TABLES
  WHERE OWNER ='user account')

cx_Oracle...


#1
Problem
ORA-12705: Cannot access NLS data files or invalid environment specified in

ORA-12705: "invalid or unknown NLS parameter value specified"
Cause: There are two possible causes:
- An attempt was made to issue an ALTER SESSION statement with an invalid NLS parameter or value.
- The NLS_LANG environment variable contains an invalid language, territory, or character set.

Solution
putenv("NLS_LANG=KOREAN_KOREA.KO16KSC5601");
putenv("ORACLE_SID=oracle9");
putenv("ORACLE_HOME=D:\oracle\ora92");
putenv("ORA_NLS33=D:\oracle\ora92\ocommon\nls\admin\data");
putenv("TNS_ADMIN=D:\oracle\ora92\network\ADMIN");

linux: export NLS_LANG=KOREAN_KOREA.KO16KSC5601
Windows console : set NLS_LANG=KOREAN_KOREA.KO16KSC5601
LINUX(UTF-8) 시스템 : NLS_LANG=KOREAN_KOREA.AL32UTF8



#2
Problem
UTF-8 Encoding

Solution
# -*- coding: utf-8 -*-

import os
os.environ['NLS_LANG'] = '.UTF8'
con=connet('user/password@ip:port/UID')
con.encoding





 

Tuesday, January 29, 2013

Review of Hyundai Capital Hacking


Hyundai Capital's information technology systems had been managed by Hyundai Autoever.
Hyundai Capital, the consumer finance unit of Hyundai Motor Group, was leaked personal information on about 420,000 of its 1.8 million customers in 2011.

금융감독원에서 발표한 현대캐피탈 해킹 보도 자료를 살펴보자.

Let's see Korean Financial Supervisory Service's audit report.

 -------------------------------------------------------------------------------------------------------------------------

[현대캐피탈 해킹, 금감원 보도 자료]
https://www.google.co.kr/url?sa=t&rct=j&q=&esrc=s&source=web&cd=4&ved=0CFAQFjAD&url=http%3A%2F%2Fwww.claimcare.co.kr%2Fbbs%2Fdownload.php%3Fbo_table%3Dclaim_pds%26wr_id%3D1078%26no%3D0&ei=HIcIUeDPGrHliQKQhoGwAQ&usg=AFQjCNFrYtpoVLWY9OrC7k2EYKL2RpbL3w&sig2=7wfiq94Nqy8Sx4H-X5jSdQ&bvm=bv.41642243,d.cGE&cad=rja

- 사고개요
3월6일~4월7일 해커가 업무관리자의 ID와 비밀번호를 습득한 뒤 보조서버인 광고메일 발송서버와 정비내역 조회서버에 침입해 화면을 복사 또는 해킹프로그램을 설치하고 다운로드하는 방식으로 약 175만명의 고객정보를 해킹했다
 * 외부에서 광고메일 발송 서버에 접속한 ID/PW 2개 및 퇴직직원의     ID/PW 1개


- 사고 발생원인

 ◦ 업무 성격상 불필요한 ID/PW 부여 및 담당직원 퇴직(1명) 후  ID/PW 미삭제**

      * 외부에서 광고메일서버에 접속가능한 ID/PW(5개) 부여
     ** 퇴직직원이 재직시 사용하던 ID/PW로 정비내역조회서버에 총 7회 무단 접속

  ◦ 해킹침입방지/차단시스템 관리 불철저

      * 해킹침입방지시스템이 2.15 ~ 4.6 기간중 해킹사고와 동일한 IP에 의한 해킹시도를 다수 적출하였음에도 해킹패턴 분석 및 해당 IP 접속 차단 등 예방조치 미실시

     ** 해킹방지 관련 아웃소싱업체와「해킹시도정보 통보기준」을 명확히 정하지  않은 점도 사고원인중 하나

  ◦ 해킹프로그램 업로드 차단 등 대응조치 미흡

       * 해킹파일로 의심되는 확장자(jsp)에 대한 필터링 기능 미비 및 파일 업로드 실행권한 제거 등 대응조치 미실시

  ◦ 해킹사고 발생시 정보유출을 최소화 할 수 있는 고객 비밀번호 암호화* 및 업무관리자의 화면 조회시 주민번호 뒷자리 숨김표시(*) 미조치 등

       * DB서버(메인시스템)내에 보관중인 고객 비밀번호는 암호화하고  있으나, 고객정보 조회․생성․변경사실 등이 기록되는 로그파일에 남아있는 고객 비밀번호 암호화는 미실시

-------------------------------------------------------------------------------------------------------------------------

Hackers only need to find one weakness to exploit, online service providers need to find and fix them.


[Suspected hacker in Hyundai Capital incident arrested in the Philippines.]
http://cybersecurityidiots.wordpress.com/2011/10/23/suspected-hacker-in-hyundai-capital-incident-arrested-in-philippines/

 
 
 

Thursday, January 24, 2013

[python] spidermonkey #1



Hi,
Have you used [SpiderMonkey] which  is Mozilla's JavaScript engine?

[SpiderMonkey]
https://developer.mozilla.org/en/docs/SpiderMonkey

[python-spidermonkey]
http://pypi.python.org/pypi/python-spidermonkey

[ref]
http://pydermonkey.googlecode.com/hg/docs/rendered/pydermonkey.html
http://code.google.com/p/python-spidermonkey/

[Code Snippet]
# -------------------------------
# run a JavaScript file
# -------------------------------

import spidermonkey

runtime = spidermonkey.Runtime()
context = runtime.new_context()

f = open("path",'r')
script = f.read()

context.eval_script(script)