2013. 7. 29. 12:31

원문출처 : http://www.autoitscript.com/forum/topic/66005-alternative-to-stringencrypt/

String.au3


This function came out of my trying to understand a supposed problem with _StringEncrypt(). Only one user reported that problem, and it was never duplicated by anyone else, so it very well may not be a bug, and this is not an attempt to "fix" _StringEncrypt().

The only thing I wanted to achieve was a version of _StringEncrypt() that would output a "standard" result for RC4 encryption, that would match RC4 implementations on web sites and in other languages. The encryption side of that was completely solved by SkinnyWhiteGuy in the topic: equal encrypt function autoit and php

What I did here was match the string-based nature of _StringEncrypt(), vice the binary nature of RC4(), with the multi-pass encryption functionality provided by the $i_EncryptLevel parameter. The result is __StringEncrypt(), with the double-underbar in the name.

Here is the function, within a basic test script:

AutoIt          
$sString = "This is a text string" ConsoleWrite("Debug: $sString = " & $sString & @LF) $sKey = "Key phrase" ConsoleWrite("Debug: $sKey = " & $sKey & @LF) For $z = 1 To 4     ConsoleWrite("Debug: Encryption level = " & $z & @LF)     $sEncrypted = __StringEncrypt(1, $sString, $sKey, $z)     ConsoleWrite("Debug: $sEncrypted = " & $sEncrypted & @LF)     $sDecrypted = __StringEncrypt(0, $sEncrypted, $sKey, $z)     ConsoleWrite("Debug: $sDecrypted = " & $sDecrypted & @LF) Next ;=============================================================================== ; ; Function Name:    __StringEncrypt() ; Description:      RC4 Based string encryption/decryption ; Parameter(s):     $i_Encrypt - 1 to encrypt, 0 to decrypt ;                   $s_EncryptText - string to encrypt ;                   $s_EncryptPassword - string to use as an encryption password ;                   $i_EncryptLevel - integer to use as number of times to encrypt string ; Requirement(s):   None ; Return Value(s):  On Success - Returns the encrypted string ;                   On Failure - Returns a blank string and sets @error = 1 ; Author(s):        (Original _StringEncrypt) Wes Wolfe-Wolvereness <Weswolf at aol dot com> ;                   (Modified __StringEncrypt) PsaltyDS at www.autoitscript.com/forum ;                   (RC4 function) SkinnyWhiteGuy at www.autoitscript.com/forum ;=============================================================================== ;  1.0.0.0  |  03/08/08  |  First version posted to Example Scripts Forum ;=============================================================================== Func __StringEncrypt($i_Encrypt, $s_EncryptText, $s_EncryptPassword, $i_EncryptLevel = 1)     Local $RET, $sRET = "", $iBinLen, $iHexWords         ; Sanity check of parameters     If $i_Encrypt <> 0 And $i_Encrypt <> 1 Then         SetError(1)         Return ''     ElseIf $s_EncryptText = '' Or $s_EncryptPassword = '' Then         SetError(1)         Return ''     EndIf     If Number($i_EncryptLevel) <= 0 Or Int($i_EncryptLevel) <> $i_EncryptLevel Then $i_EncryptLevel = 1         ; Encrypt/Decrypt     If $i_Encrypt Then         ; Encrypt selected         $RET = $s_EncryptText         For $n = 1 To $i_EncryptLevel             If $n > 1 Then $RET = Binary(Random(0, 2 ^ 31 - 1, 1)) & $RET & Binary(Random(0, 2 ^ 31 - 1, 1)) ; prepend/append random 32bits             $RET = rc4($s_EncryptPassword, $RET) ; returns binary         Next                 ; Convert to hex string         $iBinLen = BinaryLen($RET)         $iHexWords = Int($iBinLen / 4)         If Mod($iBinLen, 4) Then $iHexWords += 1         For $n = 1 To $iHexWords             $sRET &= Hex(BinaryMid($RET, 1 + (4 * ($n - 1)), 4))         Next         $RET = $sRET     Else         ; Decrypt selected         ; Convert input string to primary binary         $RET = Binary("0x" & $s_EncryptText) ; Convert string to binary                 ; Additional passes, if required         For $n = 1 To $i_EncryptLevel             If $n > 1 Then                 $iBinLen = BinaryLen($RET)                 $RET = BinaryMid($RET, 5, $iBinLen - 8) ; strip random 32bits from both ends             EndIf             $RET = rc4($s_EncryptPassword, $RET)         Next         $RET = BinaryToString($RET)     EndIf         ; Return result     Return $RET EndFunc   ;==>__StringEncrypt ; ------------------------------------------------------- ; Function:  rc4 ; Purpose:  An encryption/decryption RC4 implementation in AutoIt ; Syntax:  rc4($key, $value) ;   Where:  $key = encrypt/decrypt key ;       $value = value to be encrypted/decrypted ; On success returns encrypted/decrypted version of $value ; Author:  SkinnyWhiteGuy on the AutoIt forums at www.autoitscript.com/forum ; Notes:  The same function encrypts and decrypts $value. ; ------------------------------------------------------- Func rc4($key, $value)     Local $S[256], $i, $j, $c, $t, $x, $y, $output     Local $keyLength = BinaryLen($key), $valLength = BinaryLen($value)     For $i = 0 To 255         $S[$i] = $i     Next     For $i = 0 To 255         $j = Mod($j + $S[$i] + Dec(StringTrimLeft(BinaryMid($key, Mod($i, $keyLength) + 1, 1), 2)), 256)         $t = $S[$i]         $S[$i] = $S[$j]         $S[$j] = $t     Next     For $i = 1 To $valLength         $x = Mod($x + 1, 256)         $y = Mod($S[$x] + $y, 256)         $t = $S[$x]         $S[$x] = $S[$y]         $S[$y] = $t         $j = Mod($S[$x] + $S[$y], 256)         $c = BitXOR(Dec(StringTrimLeft(BinaryMid($value, $i, 1), 2)), $S[$j])         $output = Binary($output) & Binary('0x' & Hex($c, 2))     Next     Return $output EndFunc   ;==>rc4



These are the results of two consecutive runs in SciTE:

>Running:(3.2.10.0):C:\Program Files\AutoIt3\autoit3.exe "C:\Program Files\AutoIt3\Scripts\Test_1.au3"  Debug: $sString = This is a text string Debug: $sKey = Key phrase Debug: Encryption level = 1 Debug: $sEncrypted = 13BFA0643B2D2B75A2FA41A98B0B363748DB0EC8C5 Debug: $sDecrypted = This is a text string Debug: Encryption level = 2 Debug: $sEncrypted = FC92DD7408FBF831F8F71EB9518557EDB7A25191EAB226AEB9CF3776E3 Debug: $sDecrypted = This is a text string Debug: Encryption level = 3 Debug: $sEncrypted = 553996021B3DCE57CB21CDFD0B8808FD6D2C304B15CB79F796C76BA4680B031A03B2175035 Debug: $sDecrypted = This is a text string Debug: Encryption level = 4 Debug: $sEncrypted = BCB5DD4D8F19ED1D98BF8285385EDBB937216F5BCF45182D69BE34FD472FE0D6CE404C747C269F35C8F27D790C Debug: $sDecrypted = This is a text string +>13:06:59 AutoIT3.exe ended.rc:0



>Running:(3.2.10.0):C:\Program Files\AutoIt3\autoit3.exe "C:\Program Files\AutoIt3\Scripts\Test_1.au3"  Debug: $sString = This is a text string Debug: $sKey = Key phrase Debug: Encryption level = 1 Debug: $sEncrypted = 13BFA0643B2D2B75A2FA41A98B0B363748DB0EC8C5 Debug: $sDecrypted = This is a text string Debug: Encryption level = 2 Debug: $sEncrypted = 3F83796908FBF831F8F71EB9518557EDB7A25191EAB226AEB9261552D2 Debug: $sDecrypted = This is a text string Debug: Encryption level = 3 Debug: $sEncrypted = 4FEEF71FB98E811CCB21CDFD0B8808FD6D2C304B15CB79F796C76BA468D39E1676FC9FAA1A Debug: $sDecrypted = This is a text string Debug: Encryption level = 4 Debug: $sEncrypted = 600821594D0853343717D6DA385EDBB937216F5BCF45182D69BE34FD472FE0D6CE1CC2B3258B0833861A82BA52 Debug: $sDecrypted = This is a text string +>13:08:34 AutoIT3.exe ended.rc:0



Note that the encrypted string is the same between the two runs where $i_EncryptLevel = 1, but is different where $i_EncryptLevel > 1. It is useful in some contexts to get different results that can still be decrypted with same key to the same value.

As long as $i_EncryptLevel = 1, this function should be directly compatible with string-based RC4 implementations elsewhere (on web sites or in applications). For example, you'll get the same result if you put the string "This is a text string" and the key "Key phrase" into this web site: http://www.4guysfromrolla.com/

:) 

Posted by 땡보
2013. 7. 8. 20:42

아두이노 LED 제어 실습01~~



LED 제어 실습 02~~


허허... 그놈 참 재미지구려~~

Posted by 땡보
2013. 5. 17. 07:27

Reverse Engineering Firmware: Linksys WAG120N

The ability to analyze a firmware image and extract data from it is extremely useful. It can allow you to analyze an embedded device for bugs, vulnerabilities, or GPL violations without ever having access to the device.

In this tutorial, we’ll be examining the firmware update file for the Linksys WAG120N with the intent of finding and extracting the kernel and file system from the firmware image. The firmware image used is for the WAG120N hardware version 1.0, firmware version 1.00.16 (ETSI) Annex B, released on 08/16/2010 and is currently available for download from the Linksys Web site.

The first thing to do with a firmware image is to run the Linux file utility against it to make sure it isn’t a standard archive or compressed file. You don’t want to sit down and start analyzing a firmware image only to realize later that it’s just a ZIP file:

OK, it’s nothing known to the file utility. Next, let’s do a hex dump and run strings on it:

Taking a look at the strings output, we see references to the U-Boot boot loader and the Linux kernel. This is encouraging, as it suggests that this device does in fact run Linux, and U-Boot is a very common and well documented boot loader:

However, taking a quick look at the hexdump doesn’t immediately reveal anything interesting:

So let’s run binwalk against the firmware image to see what it can identify for us. There are a lot of false positive matches (these will be addressed in the up-coming 0.3.0 release!), but there are a few results that stand out:

Binwalk has found two uImage headers (which is the header format used by U-Boot), each of which is immediately followed by an LZMA compressed file.

Binwalk breaks out most of the information contained in these uImage headers, including their descriptions: ‘u-boot image’ and ‘MIPS Linux-2.4.31′. It also shows the reported compression type of ‘lzma’. Since each uImage header is followed by LZMA compressed data, this information appears to be legitimate.

The LZMA files can be extracted with dd and then decompressed with the lzma utility. Don’t worry about specifying a size limit when running dd; any trailing garbage will be ignored by lzma during decompression:

We are now left with the decompressed files ‘uboot’ and ‘kernel’. Running strings against them confirms that they are in fact the U-Boot and Linux kernel images:

We’ve got the kernel and the boot loader images, now all that’s left is finding and extracting the file system. Since binwalk didn’t find any file systems that looked legitimate, we’re going to have to do some digging of our own.

Let’s run strings against the extracted Linux kernel and grep the output for any file system references; this might give us a hint as to what file system(s) we should be looking for:

Ah! SquashFS is a very common embedded file system. Although binwalk has several SquashFS signatures, it is not uncommon to find variations of the ‘sqsh’ magic string (which indicates the beginning of a SquashFS image), so what we may be looking for here is a non-standard SquashFS signature inside the firmware file.

So how do we find an unknown signature inside a 4MB binary file?

Different sections inside of firmware images are often aligned to a certain size. This often means that there will have to be some padding between sections, as the size of each section will almost certainly not fall exactly on this alignment boundary.

An easy way to find these padded sections is to search for lines in our hexdump output that start with an asterisk (‘*’). When hexdump sees the same bytes repeated many times, it simply replaces those bytes with an asterisk to indicate that the last line was repeated many times. A good place to start looking for a file system inside a firmware image is immediately after these padded sections of data, as the start of the file system will likely need to fall on one of these aligned boundaries.

There are a couple interesting sections that contain the string ‘sErCoMm’. This could be something, but given the small size of some of these sections and the fact that they don’t appear to have anything to do with SquashFS, it is unlikely:

There are some other sections as well, but again, these are very small, much too small to be a file system:

Then we come across this section, which has the string ‘sqlz’ :

The standard SquashFS image starts with ‘sqsh’, but we’ve already seen that the firmware developers have used LZMA compression elsewhere in this image. Also, most firmware that uses SquashFS tends to use LZMA compression instead of the standard zlib compression. So this signature could be a modified SquashFS signature that is a concatination of ‘sq’ (SQuashfs) and ‘lz’ (LZma). Let’s extract it with dd and take a look:

Of course, ‘sqlz’ is not a standard signature, so the file utility still doesn’t recognize our extracted data. Let’s try editing the ‘sqlz’ string to read ‘sqsh’:

Running file against our modified SquashFS image gives us much better results:

This definitely looks like a valid SquashFS image! But due to the LZMA compression and the older SquashFS version (2.1),  you won’t be able to extract any files from it using the standard SquashFS tools. However, using the unsquashfs-2.1 utility included in Jeremy Collake’s firmware mod kitworks perfectly:

Now that we know this works, we should go ahead and add this new signature to binwalk so that it will identify the ‘sqlz’ magic string in the future. Adding this new signature is as easy as opening binwalk’s magic file (/etc/binwalk/magic), copy/pasting the ‘sqsh’ signature and changing the ‘sqsh’ to ‘sqlz’:

Re-running binwalk against the original firmware image, we see that it now correctly identifies the SquashFS entry:

And there you have it. We successfully identified and extracted the boot loader, kernel and file system from this firmware image, plus we have a new SquashFS signature to boot!

'Study > linux' 카테고리의 다른 글

[Backtrack]ssh 설정  (0) 2013.08.06
[펌]우분투 APM 셋팅법  (0) 2013.08.04
[명령어]서비스 재시작  (0) 2013.08.04
[Ubuntu]BackTrack5 터미널 글꼴 겹침 현상 제거  (0) 2012.08.19
Posted by 땡보
2013. 5. 3. 15:31

원문출처 : 

http://www.dbguide.net/db.db?cmd=view&boardUid=13724&boardConfigUid=9&categoryUid=216&boardIdx=58&boardStep=1

ESQL/C Programming Highlights

Overview
ESQL/C
  • C 프로그램 내에 sql 구문을 바로 넣어 그 실행 결과를 프로그램에서 다양하게 사용할 수 있도록 제공되는 어플리케이션 개발 tool
  • ESQL/C 의 주된 component는 preprocessor 로서 ESQL/C code 를 C code로 변환하여 C compiler에게 에게 넘겨준다.
ESQL/C 프로그램 작성 규칙
  • ESQL/C preprocessor가 다른 C code와 구별할 수 있게 하기 위해 SQL은 “$” 혹은 “EXEC SQL” 으로 시작
  • SQL 구문의 끝에는 “;”를 붙임.
  • SQL 구문 안의 변수(host 변수라 부름)는 변수 이름 앞에 “:”를 붙임.
  • 주석은 표준 C의 주석인 “/* */ ”사용
ESQL/C 프로그램 컴파일
  • esql l [-e] [preprocessor e] [preprocessor 옵 옵션] [cc 매개변수] [-o 실행파일] ] 소스. ec
    [링크옵션]
include에 지정된 지정된 파일을 찾는 순서
  • 현재 디렉토리
  • 컴파일시 -I 옵션으로 지정한 디렉토리
  • $INFORMIXDIR/incl/esql
  • /usr/include
다음과 같은 preprocessor 구문을 사용할 수 있다
  • define, undef
  • ifdef, elseif, else, endif, ifndef
  • 예제
    EXEC SQL define USERTRANSACTIONS;
    EXEC SQL ifdef USERTRANSACTIONS;
    EXEC SQL begin work;
    EXEC SQL endif;

그림 1: include

Host variables
호스트 변수 : SQL 데이터를 저장하는 C 변수
대소문자 구분
SQL 문장안에서 컬럼명과 구분하기 위하여 호스트변수 앞에 : 기호 사용
선언
  • 달러 기호 사용
    $ CHAR * desc ;
  • EXEC SQL 키워드 사용
    EXEC SQL begin declare section;
    char * desc;
    EXEC SQL end declare section;
사용
  • SQL 내에서
    EXEC SQL update customer set zipcode = : zipcode ;
  • C 구문 안에서
    gets (dbname);
    EXEC SQL database : dbname;
external 이나 static 으로 선언하지 않은 경우자동적으로 local 범위

그림 2: local 범위

Database Connections
ESQL/C 구문
  • CONNECT TO 데이터베이스명
  • DISCONNECT ALL
CONNECT 구문의 옵션
  • Connection 이름
    · EXEC SQL CONNECT TO ‘‘stores@ munish’AS ‘munich_con’;
  • User 절
    · EXEC SQL CONNECT TO ‘stores@ munish’ USER :uid USING : passwd ;
  • Default 절 (데이터베이스를 오픈하지 않고 서버에 연결)
    · EXEC SQL CONNECT TO DEFAULT ;
    · Default 절 사용 후 다음과 같은 문장이 필요
    √ DATABASE
    √ CREATE DATABASE
    √ START DATABASE
연결 전환 (switching)
  • 구문
    EXEC SQL SET CONNECTION ‘munish _con’;
    EXEC SQL SET CONNECTION :connect_id ;
    EXEC SQL SET CONNECTION DEFAULT;
연결 종료 (disconnecting)
  • 열린 데이터베이스를 닫고 connection을 종료한다
    EXEC SQL DISCONNECT :connect_id ;
    EXEC SQL DISCONNECT CURRENT ;
    EXEC SQL DISCONNECT DEFAULT ;
    EXEC SQL DISCONNECT ALL ;
  • default로 connect 했거나 connection이 하나 일 경우 DEFAULT 사용
Error Handling
SQL 문을 실행한 후 서버에서 SQLCA라 불리는 영역에 feedback 정보를 남긴다
  • errors
  • performance
  • warnings
SQLCODE 는 sqlca. sqlcode 값과 같다
  • SQLCODE < 0 : 에러 코드 값
  • SQLCODE = 0 : 정상적 처리
  • SQLCODE = 100 : SQLNOTFOUND, 찾는 행이 없음
  • SQLCODE = 1~99 : Dynamic SQL
에러 메시지를 얻기 위한 함수
  • rgetmsg, rgetlmsg
SQL 문이 실행되고 다음과 같은 4가지 중 하나의 상태가 된다
  • 성공
  • 성공, 찾을 수 있는 데이터는 없음
  • 성공, 경고(warning) 메시지가 있음
  • 실패
성공 외의 나머지 상태에 대한 처리 방법을 exception처리로 제어한다
  • WHENEVER exception action
  • exception : NOT FOUND, SQLWARNING, SQLERROR
  • action : GO TO label, CALL function, STOP, CONTINUE
  • 디폴트 action은 CONTINUE
WHENEVER 문의 scope는 한 소스 파일에서 global 성격을 가진다
struct sqlca_s {
long sqlcode ;
char sqlerrm[72] ;
char sqlerrp[8] ;
long sqlerrd[6] ;
struct sqlcaw_s {
char sqlwarn0 ;
char sqlwarn0 ;
char sqlwarn0 ;
char sqlwarn0 ;
char sqlwarn0 ;
char sqlwarn0 ;
char sqlwarn0 ;
char sqlwarn0 ;
} sqlwarn;
} ;
extern structsqlca_s sqlca;
GET DIAGNOSTICS 사용
  • GET DIAGNOSTICS 문은 여러 개의 SQL exception을 처리할 수 있고, ANSI및 X/OPEN 표준으로 컴파일된다
  • SQLCA 는 계속 사용 가능하다
  • 다음 세가지 분류로 사용한다
    • · SQLSTATE
    • · GET DIAGNOSTICS 문
    • · GET DIAGNOSTICS EXCEPTION 문
  • GET DIAGNOSTICS 의 정보
    • · MORE : 모든 exception이 반환되었음을 나타냄
    • · NUMBER : exception의 갯수
    • · ROW_COUNT : SQL 에 의해 처리된 행 수
  • EXCEPTION 의 정보
    • · RETURNED_SQLSTATE
    • · SERVER_NAME
    • · CONNECTION_NAME
    • · CLASS_ORIGIN 등

그림 3: GET DIAGNOSTICS 사용

Indicator 사용
  • 데이터를 호스트변수에 저장할 때 다음과 같은 Exception 이 발생할 수 있다
    • · NULL 값을 fetch 하였다
    • · 컬럼 데이터에 비해 호스트 변수의 크기가 작다
  • 사용법
    • · :host 변수:indicator 변수
    • · $host 변수 $indicator 변
    • · :host 변수 INDICATOR indicator 변수 (ANSI 표준)

그림 4: Indicator 사용

Prepare, Execute
Prepare / Execute 구문

PREPARE prepare_statement_id FROM { “quoted_string” | :host_variable } ;
EXECUTE prepare_statement_id [ USING :host_variables ]

단일 SQL문 처리 예

EXEC SQL insert into customer (customer_num, fname, lname , company)
values (0, : fname, :lname , ‘MPS Corp’ );
EXEC SQL insert into items values (: itemsrec);
※ itemsrec 변수는 items 테이블의 컬럼 순서로 선언된 structure 형

PREPARE / EXECUTE 사용

EXEC SQL PREPARE ins_p from
“insert into customer (customer_num, fname , lname, company)
values (0,?,?,?)” ;
EXEC SQL EXECUTE ins_p using : fnam, lname , :company;

PREPARE를 사용하는 이유
  • PREPARE 시점에 SQL문장에 대하여 미리 parsing되고 query plan이 생성된다
  • EXECUTE 시점에는 처리해야 할 값만 넘겨주면 즉시 실행된다
  • 하나의 DML문장에서 여러번 값을 바꿔서 넘겨주어야 할 때 PREPARE 에서 한 번만 query plan을 생성하므로 유용하게 사용할 수 있다
Cursor
Cursor 이해
  • Cursor 는 select 구문에 의해 선택된 row 들을 가리키고 있는 일종의 marker라고 볼 수 있음.
  • 여러 개의 row 를 가져오는 select 문의 결과에 대해 처리하기 위해서 필요함.
  • Cursor 종류
    • Select cursor
    • √ Scroll cursor
    • √ Non-scroll cursor
    • √ For update cursor
  • Insert cursor

그림 5: Cursor 이해

Scroll Cursor
구문
  • DECLARE
    DECLARE cursor_id SCROLL CURSOR [WITH HOLD] FOR select_stmt;
  • OPEN
    OPEN cursor_id ;
  • FETCH
    FETCH [position] Cursor_id [INTO host_variable_list] ;
    Position : FIRST, LAST, CURRENT, NEXT, PREVIOUS, ABSOLUTE n, RELATIVE n

그림 6: Scroll Cursor

  • CLOSE
    CLOSE cursor_id ;
  • FREE
    FREE Cursor_id ;
WITH HOLD 구문
  • WITH HOLD 구문을 사용한 커서는 transaction이 종료되어도 close되지 않는다.
Fetch Buffer Size
  • 환경변수 : export FET_BUF_SIZE=30000
  • 전역변수 : EXEC SQL include sqlhdr ;
    FetBufSize=30000 ;

그림 7: Fetch Buffer Size

Deferred Prepare
  • 환경변수 : export IFX_DEFERRED_PREPARE=1 (enable)
             export IFX_DEFERRED_PREPARE=0 (disable)
  • SQL 구문 : EXEC SQL set deferred_prepare ;
             EXEC SQL set deferred_prepare enabled ;
             EXEC SQL set deferred_prepare disabled ;
Open-Fetch-Close
  • 환경변수 : export OPTOFC=1 (enable)
         export OPTOFC=0 (disable)
Autofree
  • 환경변수 : export IFX_AUTOFREE=1 (enable)
              export IFX_AUTOFREE=0 (disable)
  • SQL 구문 : EXEC SQL set autofree; ;           EXEC SQL set autofree enabled ;           EXEC SQL set autofree disabled ;

그림 8: Autofree

For Update Cursor
구문
  • DECLARE
    DECLARE cursor_id CURSOR [WITH HOLD] FOR select_stmt FOR UPDATE ;
  • OPEN
    OPEN cursor_id ;
  • FETCH
    FETCH cursor_id [INTO host_variable_list] ;
  • UPDATE
    UPDATE ... WHERE CURRENT OF cursor_id ;
  • CLOSE
    CLOSE cursor_id ;
  • FREE
    FREE cursor_id ;

그림 9: Update Cursor

Insert Cursor
구문
  • DECLARE
    DECLARE cursor_id CURSOR FOR insert_stmt ;
  • OPEN
    OPEN cursor_id ;
  • PUT
    PUT cursor_id [ FROM host_variable_list ] ;
  • FLUSH
    FLUSH cursor_id ;
  • CLOSE
    CLOSE cursor_id ;
  • FREE
    FREE cursor_id ;

Posted by 땡보
2013. 1. 26. 20:57

Win 환경에선 괜츈함...

http://code.google.com/p/pyodbc/ 요기서 찾을수 있고~~

pyodbc-3.0.6.win32-py2.7.exe


'Study > python' 카테고리의 다른 글

[연습]Python regular expression & sqlite  (0) 2013.09.22
[펌]Unicode In Python, Completely Demystified  (0) 2013.09.18
Encoding type table  (0) 2012.12.27
손삼 마물단계  (0) 2012.04.04
파이썬(python)3 py to exe cx_Freeze(like py2exe)  (0) 2012.04.03
Posted by 땡보
2012. 12. 27. 07:59
CodecAliasesLanguagesascii646, us-asciiEnglishbig5big5-tw, csbig5Traditional Chinesebig5hkscsbig5-hkscs, hkscsTraditional Chinesecp037IBM037, IBM039Englishcp424EBCDIC-CP-HE, IBM424Hebrewcp437437, IBM437Englishcp500EBCDIC-CP-BE, EBCDIC-CP-CH, IBM500Western Europecp720 Arabiccp737 Greekcp775IBM775Baltic languagescp850850, IBM850Western Europecp852852, IBM852Central and Eastern Europecp855855, IBM855Bulgarian, Byelorussian, Macedonian, Russian, Serbiancp856 Hebrewcp857857, IBM857Turkishcp858858, IBM858Western Europecp860860, IBM860Portuguesecp861861, CP-IS, IBM861Icelandiccp862862, IBM862Hebrewcp863863, IBM863Canadiancp864IBM864Arabiccp865865, IBM865Danish, Norwegiancp866866, IBM866Russiancp869869, CP-GR, IBM869Greekcp874 Thaicp875 Greekcp932932, ms932, mskanji, ms-kanjiJapanesecp949949, ms949, uhcKoreancp950950, ms950Traditional Chinesecp1006 Urducp1026ibm1026Turkishcp1140ibm1140Western Europecp1250windows-1250Central and Eastern Europecp1251windows-1251Bulgarian, Byelorussian, Macedonian, Russian, Serbiancp1252windows-1252Western Europecp1253windows-1253Greekcp1254windows-1254Turkishcp1255windows-1255Hebrewcp1256windows-1256Arabiccp1257windows-1257Baltic languagescp1258windows-1258Vietnameseeuc_jpeucjp, ujis, u-jisJapaneseeuc_jis_2004jisx0213, eucjis2004Japaneseeuc_jisx0213eucjisx0213Japaneseeuc_kreuckr, korean, ksc5601, ks_c-5601, ks_c-5601-1987, ksx1001, ks_x-1001Koreangb2312chinese, csiso58gb231280, euc- cn, euccn, eucgb2312-cn, gb2312-1980, gb2312-80, iso- ir-58Simplified Chinesegbk936, cp936, ms936Unified Chinesegb18030gb18030-2000Unified Chinesehzhzgb, hz-gb, hz-gb-2312Simplified Chineseiso2022_jpcsiso2022jp, iso2022jp, iso-2022-jpJapaneseiso2022_jp_1iso2022jp-1, iso-2022-jp-1Japaneseiso2022_jp_2iso2022jp-2, iso-2022-jp-2Japanese, Korean, Simplified Chinese, Western Europe, Greekiso2022_jp_2004iso2022jp-2004, iso-2022-jp-2004Japaneseiso2022_jp_3iso2022jp-3, iso-2022-jp-3Japaneseiso2022_jp_extiso2022jp-ext, iso-2022-jp-extJapaneseiso2022_krcsiso2022kr, iso2022kr, iso-2022-krKoreanlatin_1iso-8859-1, iso8859-1, 8859, cp819, latin, latin1, L1West Europeiso8859_2iso-8859-2, latin2, L2Central and Eastern Europeiso8859_3iso-8859-3, latin3, L3Esperanto, Malteseiso8859_4iso-8859-4, latin4, L4Baltic languagesiso8859_5iso-8859-5, cyrillicBulgarian, Byelorussian, Macedonian, Russian, Serbianiso8859_6iso-8859-6, arabicArabiciso8859_7iso-8859-7, greek, greek8Greekiso8859_8iso-8859-8, hebrewHebrewiso8859_9iso-8859-9, latin5, L5Turkishiso8859_10iso-8859-10, latin6, L6Nordic languagesiso8859_13iso-8859-13, latin7, L7Baltic languagesiso8859_14iso-8859-14, latin8, L8Celtic languagesiso8859_15iso-8859-15, latin9, L9Western Europeiso8859_16iso-8859-16, latin10, L10South-Eastern Europejohabcp1361, ms1361Koreankoi8_r Russiankoi8_u Ukrainianmac_cyrillicmaccyrillicBulgarian, Byelorussian, Macedonian, Russian, Serbianmac_greekmacgreekGreekmac_icelandmacicelandIcelandicmac_latin2maclatin2, maccentraleuropeCentral and Eastern Europemac_romanmacromanWestern Europemac_turkishmacturkishTurkishptcp154csptcp154, pt154, cp154, cyrillic-asianKazakhshift_jiscsshiftjis, shiftjis, sjis, s_jisJapaneseshift_jis_2004shiftjis2004, sjis_2004, sjis2004Japaneseshift_jisx0213shiftjisx0213, sjisx0213, s_jisx0213Japaneseutf_32U32, utf32all languagesutf_32_beUTF-32BEall languagesutf_32_leUTF-32LEall languagesutf_16U16, utf16all languagesutf_16_beUTF-16BEall languages (BMP only)utf_16_leUTF-16LEall languages (BMP only)utf_7U7, unicode-1-1-utf-7all languagesutf_8U8, UTF, utf8all languagesutf_8_sig all languages

'Study > python' 카테고리의 다른 글

[펌]Unicode In Python, Completely Demystified  (0) 2013.09.18
python ODBC 연결시~  (0) 2013.01.26
손삼 마물단계  (0) 2012.04.04
파이썬(python)3 py to exe cx_Freeze(like py2exe)  (0) 2012.04.03
[분석중]맵스캔..  (0) 2012.04.03
Posted by 땡보
2012. 12. 15. 20:57

안드로이드에서 sl4a 서버의 포트 찾기~

#!/bin/bash

# ADB
# The path to the Android Debugger program.
# By default, we use the one detected in the environment.
# This can be overridden below.
ADB=`which adb`
# FORWARDED_PORT
# SL4A RPC calls sent via FORWARDED_PORT on the localhost
# are forwarded to the SL4A server on the Android device.
FORWARDED_PORT=9999
# MAX_SERVER_RETRIES
# Max number of retries to detect the port number that
# the SL4A server is using on the Android device.
MAX_SERVER_RETRIES=3
SLEEP_TIME_BETWEEN_RETRIES=1

sanity_checks()
{
  if test -z "$ADB"
  then
echo "The Android Debugger program (adb) was not found in your path."
    echo "Please check your Android SDK installation and your PATH envronment."
    exit 1
  fi

PYTHON_SHELL=`which ipython`
  if test -z "$PYTHON_SHELL"
  then
PYTHON_SHELL=`which python`
  fi

if test -z "$PYTHON_SHELL"
  then
echo "The Python interpreter was not found in your path."
    echo "Please check your installation and your PATH envronment."
    exit 1
  fi
}


start_private_server()
{
  echo "Starting Scripting Layer for Android(SL4A) private server."
  ${ADB} shell am start -a com.googlecode.android_scripting.action.LAUNCH_SERVER -n com.googlecode.android_scripting/.activity.ScriptingLayerServiceLauncher
  echo "Waiting for ${SLEEP_TIME_BETWEEN_RETRIES}s to let server settle."
  sleep ${SLEEP_TIME_BETWEEN_RETRIES}
}


get_private_server_port()
{
  # Android's netstat app seems to be crippled. It does not accept
  # standard netstat switches like -l and -p. A normal 'netstat -lp'
  # command would return the list of listening ports AND their
  # associated PIDs. Because Android's netstat doesn't return this
  # info, the code simply assumes that the SL4A server on the first
  # port that listens on localhost.
  # I'd welcome any suggestions for improvement here.
  SERVER_PORT=`${ADB} shell netstat | grep "127.0.0.1.*LISTEN" | awk -F "[ :]*" '{ print $6 }' | head -n 1`
  retries=0
  while test -z "$SERVER_PORT" && (( retries < $MAX_SERVER_RETRIES))
  do
echo "Server port not detected. Sleeping for ${SLEEP_TIME_BETWEEN_RETRIES}s."
    sleep ${SLEEP_TIME_BETWEEN_RETRIES}
    (( retries += 1 ))
    echo "Retry ${retries} of ${MAX_SERVER_RETRIES}."
    SERVER_PORT=`${ADB} shell netstat | grep "127.0.0.1.*LISTEN" | awk -F "[ :]*" '{ print $6 }' | head -n 1`
  done

if test -z "$SERVER_PORT"
  then
echo "Server port not detected. Please check your SL4A installation."
    exit 1
  fi

echo "Found server serving on port: ${SERVER_PORT}"
}


setup_remote_control_environment()
{
  echo "Forwarding to SL4A client requests to port: ${FORWARDED_PORT}"
  ${ADB} forward tcp:${FORWARDED_PORT} tcp:${SERVER_PORT}
  export AP_PORT=${FORWARDED_PORT}
}


sanity_checks
start_private_server
get_private_server_port
setup_remote_control_environment
echo "Starting python interpreter..."
$PYTHON_SHELL
echo "Remember to stop the SL4A server on your Android device."

Posted by 땡보
2012. 9. 17. 08:37

'Study > Reverse_engineering' 카테고리의 다른 글

[펌]SYBASE ASA DB log file error  (0) 2012.01.11
[분석중]삭제키  (0) 2011.12.28
[놀이]flickhomerun  (0) 2011.12.10
[ARM]자주 사용되는 ARM/THUMB OPCODE 정리  (0) 2011.09.29
[펌]IOS 안티 디버깅 기법  (0) 2011.09.28
Posted by 땡보
2012. 9. 15. 02:44

SELECT * FROM master..sysprocesses WHERE ipaddr = "129.100.254.242" AND suid = suser_id("pos")

Posted by 땡보
2012. 8. 20. 22:29

맥용 SSL VPN 터널링 도구

원문 : http://www.question-defense.com/2011/10/04/connect-to-fortinet-vpn-on-osx-download-forticlient-ssl-vpn-for-osx


forticlientsslvpn_macosx_4.0.2082.dmg


Posted by 땡보