CreateMutex
까보면 다나와~
분류 전체보기 (216)

windbg IAT 목록 가져오기

커널모드에서는 lm 명령어로 로드된 프로세스의 주소를 확인하면 되고

유저모드에서는 !dh 명령어로 "Import Address Table Directory" Offset을 찾는다.



dps 명령을 통해 위에서 찾은 주소값을 입력하면 IAT 목록을 확인할 수 있다.


kd> dps 00401000

00401000  7c82134b kernel32!GetWindowsDirectoryA

00401004  7c81cafa kernel32!ExitProcess

00401008  7c8260aa kernel32!DnsApiSetDebugGlobals

0040100c  7c809bd7 kernel32!CloseHandle

00401010  7c80be46 kernel32!lstrlenA

00401014  7c810e17 kernel32!WriteFile

00401018  7c80bcf9 kernel32!SizeofResource

0040101c  7c831ca8 kernel32!SetFileTime

00401020  7c83553c kernel32!LocalFileTimeToFileTime

00401024  7c810bac kernel32!SystemTimeToFileTime

00401028  7c801a28 kernel32!CreateFileA

0040102c  7c80a045 kernel32!LoadResource

00401030  7c80bf19 kernel32!FindResourceA

00401034  7c80be91 kernel32!lstrcpyA

00401038  7c80bb31 kernel32!lstrcmpiA

0040103c  7c93fe10 ntdll!RtlRestoreLastWin32Error

00401040  7c93fe01 ntdll!RtlGetLastWin32Error

00401044  7c834d59 kernel32!lstrcatA

00401048  7c814f7a kernel32!GetSystemDirectoryA


이런식으로...


참고 -

http://tomsreversing.com/2013/03/11/viewing-imports-table/

'툴 정보 및 사용법 > WinDBG' 카테고리의 다른 글

링크)windbg를 이용한 언패킹  (0) 2017.08.16
Symbol 안맞아서 볼 수 없을때  (0) 2014.07.18
bp gethostbyname  (0) 2013.07.15
windbg (호스트 win7) xp 명령어 안될때  (0) 2013.07.05
명령줄에서 심볼로드  (0) 2012.10.24
  Comments,     Trackbacks

윈도우용 파이썬 패키지 설치할 때 알아두어야 할 것

1. 유니코드 에러

UnicodeDecodeError: 'ascii' codec can't decode byte 0xc7 in position...

이건 한글 문제인거 같은데 python 설치폴더\Lib\site.py의 

def setencoding():

    encoding = "ascii" 

를 아래처럼 바꾸면 된다.

def setencoding():

    encoding = "bmcs"


2. 신텍스 에러

SyntaxError: Non-ASCII character '\xb0' in file...

설명 http://mwultong.blogspot.com/2007/01/python-syntaxerror-non-ascii-character.html

해결 : 1번 에러시 수정했던 site.py파일의 맨 상단에

# -*- coding: cp949 -*-

를 추가해 주면 된다.


인코딩에 관한건 예전에 약간 정리한게 있으니 참고하면 될듯?..


'툴 정보 및 사용법 > Python' 카테고리의 다른 글

유니코드 한글 확인하기  (0) 2019.03.20
Python 2.7 Unicode 관련  (0) 2017.03.31
Pyhon colored output string  (0) 2014.04.02
Python 코드 몇개(LCS, LRS)  (0) 2014.03.18
파이썬 팁 모음  (0) 2014.02.25
  Comments,     Trackbacks

C/C++ unicode 문자열 처리 함수

http://blog.naver.com/nawoo/80102722318


C언어는 정말 타입 정의가 너무 헷갈린다는;;ㅜ

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


멀티 바이트 환경에서 사용하던 함수를 유니코드 환경에서 사용하려고 하면 사용이 안된다.

 

처음에 VS2008을 사용하면서 예전 책을 보면서 공부할 때 가장 많이 머리가 아프던 문제였다.

 

유니코드 환경에서 사용 할 수 있게 정의가 되어진 함수들은 같은 함수명을 써도 자동으로 처리가 되기 때문에

 

특별히 신경을 쓸 일은 없었다. 그러나 문자열처리 함수 같은경우는 아예 함수 이름이 바뀌었기 때문에 모른다면 사용 할 수가 없다.

 

그래서 문자열 처리 함수를 정리 할 겸 유니코드 환경에서 사용 할 수 있는 문자열 처리 함수를 정리해 보았다.

 

 

일단 기본적으로 멀티 바이트 환경에서 문자열 처리 함수의 접두어는 str 이었다 strlen, strcat, strstr 등등

 

그러나 유니코드 환경에서 접두어는 wcs이다. 이것만 기억해 둔다면 이미 문자열처리 함수의 절반은 안것이다.

 

 

1-1.strcpy -> wcscpy

 

:문자열을 복사하는 함수이다

 

원형 :

wchar_t *wcscpy(
   wchar_t *strDestination,           복사 당하는 대상
   const wchar_t *strSource           복사 하려는 소스
); 

ex)

TCHAR str[256];

wcscpy(str,L"안녕하세요");

TextOut(hdc,0,0,str,wcslen(str));

 

:결과 = 0,0에 "안녕하세요" 문자열 출력

 

 

1-2. strncpy -> wcsncpy

 

:입력한 사이즈 만큼 문자열을 복사하는 함수이다

 

원형 :

wchar_t *wcsncpy(
   wchar_t *strDest,                복사 당하는 대상
   const wchar_t *strSource,        박사 하려는 소스
   size_t count                     복사하려는 개수
); 

ex)

TCHAR str[256];

memset(str,0,sizeof(str));                  NULL값으로 배열을 초기화

wcsncpy(str,L"안녕하세요", 2);

TextOut(hdc,0,0,str,wcslen(str));

 

:결과 = 0,0에 "안녕" 문자열 출력

 

 

2. strlen -> wcslen

 

: 입력 받은 문자열의 길이를 반환해준다.

sizeof와 다른점은 sizeof는 배열의 전체크기를 반환해주고

wcslen은 중간에 NULL을 만나면 NULL까지의 길이만 반환한다.

 

원형 :

size_t wcslen(
   const wchar_t *str 
);

 

 

3-1.strcat -> wcscat

 

: 두 문자열을 이어준다

 

원형 :

wchar_t *wcscat(
   wchar_t *strDestination,
   const wchar_t *strSource 
); 

ex)

wcscpy(str,L"안녕하세요");
wcscat(str,L"오냐");

TextOut(hdc,0,0,str,wcslen(str));

 

:결과 = 0,0에 "안녕하세요오냐" 출력

 

 

3-2.strncat -> wcsncat

 

: 입력한 사이즈만큼 대상에 소스를 이어준다

 

원형 :

wchar_t *wcsncat(
   wchar_t *strDest,
   const wchar_t *strSource,
   size_t count 
); 

ex)

wcscpy(str,L"안녕하세요");
wcsncat(str,L"오냐",1);

TextOut(hdc,0,0,str,wcslen(str));

 

:결과 = 0,0에 "안녕하세요오" 출력

 

 

4-1.strcmp -> wcscmp

 

: 문자열을 비교한다.

 

원형 :

int wcscmp(
   const wchar_t *string1,
   const wchar_t *string2 
); 

string1과 string2가 같으면 0

string1>string2 이면 양수

string1<string2 이면 음수

 

ex)

wcscpy(str,L"안녕하세요");

wcscpy(str2,L"하이");

if(wcscmp(str,str2) == 0){

  TextOut(hdc,0,0,L"같다",2);

}else{

  TextOut(hdc,0,0,L"다르다",3);

}

:출력 = 0,0에 "다르다" 출력

 

 

4-2.strncmp -> wcsncmp

 

:지정한 사이즈만큼 대소문자를 구분하지 않고 문자열을 비교한다.

 

원형 :

int wcsncmp(
   const wchar_t *string1,
   const wchar_t *string2,
   size_t count 
);
 

string1과 string2가 같으면 0

string1>string2 이면 양수

string1<string2 이면 음수

 

ex)

wcscpy(str,L"안녕하세요");

wcscpy(str2,L"안하이");

if(wcsncmp(str,str2,1) == 0){

  TextOut(hdc,0,0,L"같다",2);

}else{

  TextOut(hdc,0,0,L"다르다",3);

}

:출력 = 0,0에 "같다" 출력

 

 

5-1. stricmp -> wcsicmp

 

:대소문자를 구별하지 않고 문자열을 비교

 

원형 :

int _wcsicmp(
   const wchar_t *string1,
   const wchar_t *string2 
); 

string1과 string2가 같으면 0

string1>string2 이면 양수

string1<string2 이면 음수

 

ex)

wcscpy(str,L"ABCDE");

wcscpy(str2,L"abcde");

if(wcsicmp(str,str2) == 0){

  TextOut(hdc,0,0,L"같다",2);

}else{

  TextOut(hdc,0,0,L"다르다",3);

}

:출력 = 0,0에 "같다" 출력

 

 

5-2. strnicmp -> wcsnicmp

 

:대소문자를 구별하지 않고 문자열을 비교

 

원형 :

int _wcsnicmp(
   const wchar_t *string1,
   const wchar_t *string2,
   size_t count 
);
 

string1과 string2가 같으면 0

string1>string2 이면 양수

string1<string2 이면 음수

 

ex)

wcscpy(str,L"ABCDE");

wcscpy(str2,L"abcdefgh");

if(wcsnicmp(str,str2,5) == 0){

  TextOut(hdc,0,0,L"같다",2);

}else{

  TextOut(hdc,0,0,L"다르다",3);

}

:출력 = 0,0에 "같다" 출력

 

 

6-1.strchr -> wcschr

 

:문자열에서 한 문자를 찾아 그 문자가 있는 주소를 반환하여 준다. (문자열의 처음부터 검사한다)

:만약에 찾지 못했을 경우에는 NULL값을 반환해준다

 

원형:

wchar_t *wcschr(
   wchar_t *str,
   wchar_t c 
); 

ex)

wcscpy(str2,L"에요안녕하세요하이");
   
TCHAR dd = L'요';
TCHAR * ddd;
   
ddd = wcschr(str2,dd);

 

TextOut(hdc,0,0,ddd,wcslen(ddd));

 

:출력 = 0,0에 "요안녕하세요하이" 출력

 

 

6-2.strrchr -> wcsrchr

 

:문자열에서 한 문자를 찾아 그 문자가 있는 주소를 반환하여 준다. (문자열의 맨 마지막부터 검색한다)

:만약에 찾지 못했을 경우에는 NULL값을 반환해준다

 

원형:

wchar_t *wcsrchr(
   wchar_t *str,
   wchar_t c 
); // C++ only

ex)

wcscpy(str2,L"에요안녕하세요하이");
   
TCHAR dd = L'요';
TCHAR * ddd;
   
ddd = wcsrchr(str2,dd);

 

TextOut(hdc,0,0,ddd,wcslen(ddd));

 

:출력 = 0,0에 "요하이" 출력

 

 

7.strstr -> wcsstr

 

:문자열에서 원하는 문자열을 찾아준다.

 

원형 :

wchar_t *wcsstr(
   wchar_t *str,
   const wchar_t *strSearch 
);

 

ex)

wcscpy(str2,L"에요안녕하세요하이");
   
TCHAR * ddd;
ddd = wcsstr(str2,L"안녕");

TextOut(hdc,0,0,ddd,wcslen(ddd)); 

:출력 = "안녕하세요하이" 출력

 

 

8.strpbrk -> wcspbrk

 

: 첫번째 인수로 받은 문자열에서 두번째 인수로 받은 문자열중 한문자라도 빨리 나오는 문자의 주소를 반환해준다.

 

원형 :

wchar_t *wcspbrk(
   wchar_t *str,
   const wchar_t *strCharSet 
); // C++ only 

ex)

wcscpy(str2,L"에요안녕하세요하이");
   
TCHAR * ddd; 

ddd = wcspbrk(str2,L"녕세");            '녕' 이나 '세' 이 두글자 중에 빨리 나오는 문자의 주소를 출력해준다

TextOut(hdc,0,0,ddd,wcslen(ddd)); 

:출력 = "녕하세요하이" 출력

 

 

9.strtok -> wcstok

 

: 첫번째 매개변수로 받은 문자열을 두번째 매개변수로 받은 토큰 문자로 나누어준다.

 

원형 :

wchar_t *wcstok(
   wchar_t *strToken,
   const wchar_t *strDelimit 
); 

ex)

wcscpy(str2,L"나의'가치'는 내가 결정하고, 당신의 '가치'는 당신이 결정한다");
TCHAR * ddd;

ddd = wcstok(str2,L" ,'");      //토큰은 여러개를 지정할 수 있다. 여기서는 공백(' ')과 콤마(',') 작은따옴표(')로 지정했다.
while(ddd != NULL){
 TextOut(hdc,0,i,ddd,wcslen(ddd));
 ddd = wcstok(NULL,L" ,'");     //검색을 계속 해야하기 때문에 NULL값을 매개변수로 넣어준다

 i+=20;
}

 

wcstok의 방식은 문자열에서 처음 토큰을 발견하면 그 주소를 저장하고 두번째 토큰을 찾아내면 그 토큰을 NULL로 만들고

 

처음 토큰 주소를 반환해준다. 또한 wcstok함수는 함수 중간 결과를 자체적으로 정적변수를 사용하고 있다. 그렇기 때문에

 

계속 검색을 하고 싶으면 첫번째 매개변수로 NULL을 넣어주면 문자열이 끝날때 까지 검색을 한다.

 

검색이 끝나면 NULL을 반환해 준다.

 

wcstok함수도 매개변수로 받은 데이터를 손상시키기 때문에 데이터가 손상되지 않게 하려면 다른곳에 복사한 후에 써야한다.

 

또한 함수 자체적으로 정적 변수를 사용하고있기 때문에 멀티 스레드 환경에서 동시에 호출될 염려가 있으므로

 

동시에 호출되지 않도록 보호해 주어야 한다.

 

:출력 =

나의

가치

내가

결정하고

당신의

가치

당신이

결정한다

 

 

10-1.strset -> wcsset

 

: 첫번째 매개변수로 받은 문자열을 NULL문자 전까지 모두 두번째 문자로 바꾼다

 

원형 :

wchar_t *_wcsset(
   wchar_t *str,
   wchar_t c 
); 

ex)

wcscpy(str,L"ABCDE");

wcsset(str,L'd');
TextOut(hdc,0,0,str,wcslen(str));

 

:출력 =  0,0에 "ddddd" 문자열이 출력된다

 

 

10-2.strnset -> wcsnset

 

: 첫번째 매개변수로 받은 문자열을 입력받은 사이즈 만큼 두번째 문자로 바꾼다

 

원형 :

wchar_t *_wcsnset(
   wchar_t *str,
   wchar_t c,
   size_t count 
);

ex)

wcscpy(str,L"ABCDE");

wcsnset(str,L'd',2);
TextOut(hdc,0,0,str,wcslen(str));

 

:출력 =  0,0에 "ddCBD" 문자열이 출력된다

 

 

11.

strupr -> wcspur

strlwr -> wcslwr

 

: 지정한 문자열을 대문자로 치환(wcspur) 하거나 소문자로 치환(wcslwr)한다.

: 단 대문자나 소문자만 치환이 되고 한글이나 숫자는 치환되지 않는다.

: 이 함수도 매개변수로 받은 문자열을 변형시키기 때문에 변형되어서는 안되는 문자열이면 복사를 해놓고 사용해야 한다.

 

wcscpy(str,L"1abcdeABCDE아");

wcsupr(str);
TextOut(hdc,0,0,str,wcslen(str)); 

wcslwr(str);
TextOut(hdc,0,20,str,wcslen(str)); 

:출력 =

0,0에 "1ABCDEABCDE아" 출력

0,20에 "1abcdeabcde아" 출력

 

12.strrev -> wcsrev

 

: 지정한 문자열을 역순으로 배치한다. 한글도 역순으로 배치된다.

: 이 함수도 매개변수로 받은 문자열을 변형시키기 때문에 변형되어서는 안되는 문자열이면 복사를 해놓고 사용해야 한다.

 

원형 :

wchar_t *_wcsrev(
   wchar_t *str 
);

ex)

wcscpy(str,L"1abcdeABCDE아");

wcscpy(str2,L"나의 '가치'는 내가 결정하고, 당신의 '가치'는 당신이 결정한다");
   
wcsrev(str);
wcsrev(str2);

TextOut(hdc,0,0,str2,wcslen(str2));
TextOut(hdc,0,20,str,wcslen(str));

:출력 =

0,0에 "다한정결 이신당 는'치가' 의신당 ,고하정결 가내 는'치가' 의나" 출력

0,20에 "아EDCBAedcba1" 출력

  Comments,     Trackbacks

Pyhon colored output string

유용~

 

http://www.siafoo.net/snippet/88

 

print '\033[1;30mGray like Ghost\033[1;m'
print '\033[1;31mRed like Radish\033[1;m'
print '\033[1;32mGreen like Grass\033[1;m'
print '\033[1;33mYellow like Yolk\033[1;m'
print '\033[1;34mBlue like Blood\033[1;m'
print '\033[1;35mMagenta like Mimosa\033[1;m'
print '\033[1;36mCyan like Caribbean\033[1;m'
print '\033[1;37mWhite like Whipped Cream\033[1;m'

Also "[1;" = bold "[0;" = normal 

 

 

 

한김에..ㅋ

  Comments,     Trackbacks

Ubuntu 삭제 파일 복구(testdisk)

http://logon.tistory.com/182


유용하네요.


but.. 복구전에 같은 파일이름을 만드는 실수...ㅜㅜ 복구 링크가 이름으로 되어있는지 새로 만든 이름이 복구 되네요..ㅜㅜ..

  Comments,     Trackbacks

유용한 리눅스 명령어 모음.. 좋네요.

http://linoxide.com/guide/linux-command-shelf.html

실제 사이트로 가서 보는게 좋겠네요.

1. SYSTEM


$ uname –a                       => Display linux system information
$ uname –r                       => Display kernel release information (refer uname command in detail)
$ cat /etc/redhat_release        => Show which version of redhat installed 
$ uptime                         => Show how long system running + load (learn uptime command)
$ hostname                       => Show system host name
$ hostname -i                    => Display the IP address of the host (all options hostname)
$ last reboot                    => Show system reboot history (more examples last command)
$ date                           => Show the current date and time (options of date command)
$ cal                            => Show this month calendar (what more in cal)
$ w                              => Display who is online (learn more about w command)
$ whoami                         => Who you are logged in as (example + sreenshots)
$ finger user                    => Display information about user (many options of finger command)

2. Hardware


$ dmesg                          => Detected hardware and boot messages (dmesg many more options)
$ cat /proc/cpuinfo              => CPU model
$ cat /proc/meminfo              => Hardware memory
$ cat /proc/interrupts           => Lists the number of interrupts per CPU per I/O device
$ lshw                           => Displays information on hardware configuration of the system
$ lsblk                          => Displays block device related information in Linux (sudo yum install util-linux-ng)
$ free -m                        => Used and free memory (-m for MB) (free command in detail)
$ lspci -tv                      => Show PCI devices (very useful to find vendor ids)
$ lsusb -tv                      => Show USB devices (read more lsusb options)
$ lshal                          => Show a list of all devices with their properties 
$ dmidecode                      => Show hardware info from the BIOS (vendor details)
$ hdparm -i /dev/sda	          # Show info about disk sda 
$ hdparm -tT /dev/sda	         # Do a read speed test on disk sda
$ badblocks -s /dev/sda	         # Test for unreadable blocks on disk sda

3. Statistics


$ top                              => Display and update the top cpu processes (30 example options)
$ mpstat 1                         => Display processors related statistics (learn mpstat command)
$ vmstat 2                         => Display virtual memory statistics (very useful performance tool)
$ iostat 2                         => Display I/O statistics (2sec Intervals) (more examples)
$ tail -n 500 /var/log/messages    => Last 10 kernel/syslog messages (everyday use tail options)
$ tcpdump -i eth1                  => Capture all packets flows on interface eth1 (useful to sort network issue)
$ tcpdump -i eth0 'port 80'        => Monitor all traffic on port 80 ( HTTP )
$ lsof                             => List all open files belonging to all active processes.(sysadmin favorite command)
$ lsof -u testuser                 => List files opened by specific user
$ free –m                          => Show amount of RAM (daily usage command)
$ watch df –h                      => Watch changeable data continuously(interesting linux command)

4. Users


$ id                                  => Show the active user id with login and group(with screenshot)
$ last                                => Show last logins on the system (few more examples)
$ who                                 => Show who is logged on the system(real user who logged in)
$ groupadd   admin                    => Add group "admin" (force add existing group)
$ useradd -c  "Sam Tomshi" -g admin -m sam  => Create user "sam" and add to group "admin"(here read all parameter)
$ userdel sam                         => Delete user sam (force,file removal)
$ adduser sam                         => Add user "sam" 
$ usermod                             => Modify user information(mostly useful for linux system admins)

5. File Commands


$ ls –al                                => Display all information about files/ directories(20 examples)
$ pwd                                   => Show current directory path(simple but need every day)
$ mkdir directory-name                  => Create a directory(create mutiple directory)
$ rm file-name                          => Delete file(be careful of using rm command)
$ rm -r directory-name                  => Delete directory recursively 
$ rm -f file-name                       => Forcefully  remove file
$ rm -rf directory-name                 => Forcefully remove directory recursively
$ cp file1 file2                        => Copy file1 to file2 (15 cd command examples)
$ cp -r dir1 dir2                       => Copy dir1 to dir2, create dir2 if it doesn’t  exist
$ mv file1 file2                        => Move files from one place to another(with 10 examples)
$ ln –s  /path/to/file-name  link-name  => Create symbolic link to file-name (examples)
$ touch file                            => Create or update file (timestamp change)
$ cat > file                            => Place standard input into file (15 cat command examples)
$ more file                             => Output the contents of file (help display long tail files)
$ head file                             => Output the first 10 lines of file (with different parameters)
$ tail file                             => Output the last 10 lines of file (detailed article with tail options)
$ tail -f file                          => Output the contents of file as it grows starting with the last 10 lines
$ gpg -c file                           => Encrypt file (how to use gpg)
$ gpg file.gpg                          => Decrypt file

6. Process Related


$ ps                               # Display your currently active processes (many parameters to learn)
$ ps aux | grep 'telnet'           # Find all process id related to telnet process
$ pmap                             # Memory map of process (kernel,user memory etc)
$ top                              # Display all running processes (30 examples)
$ kill pid                         # Kill process with mentioned pid id (types of signals)
$ killall proc                     # Kill all processes named proc
$ pkill processname                # Send signal to a process with its name
$ bg                               # Lists stopped or background jobs (bg and fg command)
$ fg                               # Brings the most recent job to foreground
$ fg n                             # Brings job n to the foreground

7. File Permission Related


$ chmod octal file-name     # Change the permissions of file to octal , which can be found separately for user, group and world
octal value  (more examples)
4 - read
2 – write
1 – execute
Example 
$ chmod 777 /data/test.c                   # Set rwx permission for owner , rwx  permission for group, rwx permission for world
$ chmod 755 /data/test.c                   # Set rwx permission for owner,rw for group and world
$ chown owner-user file                    # Change owner of the file (chown more examples)
$ chown owner-user:owner-group  file-name  # Change owner and group owner of the file
$ chown owner-user:owner-group directory   # Change owner and group owner of the directory
Example 
$ chown bobbin:linoxide test.txt
$ ls -l test.txt
-rw-r--r-- 1 bobbin linoxide 0 Mar 04 08:56 test.txt


8. Network


$ ifconfig –a                  # Display all network ports and ip address (set mtu and other all options)
$ ifconfig eth0                # Display specific  ethernet port ip address and details
$ ip addr show                 # Display all network interfaces and ip address(available in iproute2 package,powerful than ifconfig)
$ ip address add 192.168.0.1 dev eth0      # Set ip address
$ ethtool eth0                 # Linux tool to show ethernet status (set full duplex , pause parameter)
$ mii-tool  eth0               # Linux tool to show  ethernet status (more or like ethtool)
$ ping host                    # Send echo request to test connection (learn sing enhanced ping tool)
$ whois domain                 # Get who is information for domain
$ dig domain                   # Get DNS information for domain (screenshots with other available parameters)
$ dig  -x host                 # Reverse lookup host 
$ host google.com              # Lookup DNS ip address for the name (8 examples of host command)
$ hostname –i                  # Lookup local ip address (set hostname too)
$ wget file                    # Download file (very useful other option)
$ netstat  -tupl               # Listing all active listening ports(tcp,udp,pid) (13 examples)

9. Compression / Archives


$ tar cf home.tar  home              # Create tar named home.tar containing home/ (11 tar examples)
$ tar xf file.tar                    # Extract the files from file.tar
$ tar czf  file.tar.gz  files        # Create a tar with gzip compression
$ gzip file                          # Compress file and renames it to file.gz (untar gzip file)

10. Install Package


$ rpm -i pkgname.rpm                         # Install rpm based package (Installing, Uninstalling, Updating, Querying ,Verifying)
$ rpm -e pkgname                             # Remove package
Install from source
./configure
make
make install (what it is)

12. Login (ssh and telnet)


$ ssh user@host                         # Connect to host as user (secure data communication command)
$ ssh  -p port user@host                # Connect to host using specific port
$ telnet host                           # Connect to the system using  telnet port

13. File Transfer


scp
$ scp file.txt   server2:/tmp                   # Secure copy file.txt to remote host  /tmp folder
$ scp nixsavy@server2:/www/*.html   /www/tmp    # Copy *.html files from remote host to current system /www/tmp folder
$ scp -r nixsavy@server2:/www   /www/tmp        # Copy all files and folders recursively from remote server to the current system /www/tmp folder
rsync
$ rsync -a /home/apps /backup/                  # Synchronize source to destination
$ rsync -avz /home/apps linoxide@192.168.10.1:/backup    # Synchronize files/directories between the local and remote system with compression enabled

14. Disk Usage


$ df –h                         # Show free space on mounted filesystems(commonly used command)
$ df -i	                        # Show free inodes on mounted filesystems
$ fdisk -l	                # Show disks partitions sizes and types(fdisk command output)
$ du -ah                        # Display disk usage in human readable form (command variations)
$ du -sh                        # Display total disk usage on the current directory
$ findmnt                        # Displays target mount point for all filesystem 
$ mount device-path mount-point  # Mount a device 

15. Directory Traverse


$ cd ..                              # To go up one level of the directory tree(simple & most needed)
$ cd	                             # Go to $HOME directory
$ cd /test                           # Change to /test directory

 

  Comments,     Trackbacks

Python 코드 몇개(LCS, LRS)

LCS는 알고리즘으로 가장 긴 공통 문자열을 찾는다.

*Longest Common Substring(subsequence)

def longest_common_substring(s1, s2):
    m = [[0] * (1 + len(s2)) for i in xrange(1 + len(s1))]
    longest, x_longest = 0, 0
    for x in xrange(1, 1 + len(s1)):
        for y in xrange(1, 1 + len(s2)):
            if s1[x - 1] == s2[y - 1]:
                m[x][y] = m[x - 1][y - 1] + 1
                if m[x][y] > longest:
                    longest = m[x][y]
                    x_longest = x
            else:
                m[x][y] = 0
    return s1[x_longest - longest: x_longest]


def main():
    a = "12345123jdfjdfjdfjdf"
    b= "s902384jdf9123 jdfj"
    print longest_common_substring(a, b)
   
if __name__ == "__main__":
    try:
        main()
    except KeyboardInterrupt:
        print "User aborted."
    except SystemExit:
        pass

 

 

LRS는 가장 긴 반복 문자열을 찾는다.

*Longest Repeated Substring

from collections import Counter
a='aaabbbsdfsdfasdfbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbaaaa34243sfsaef'
times=3
for n in range(1,len(a)/times+1)[::-1]:
substrings=[a[i:i+n] for i in range(len(a)-n+1)]
freqs=Counter(substrings)
if freqs.most_common(1)[0][1]>=3:
seq=freqs.most_common(1)[0][0]
break
print "sequence '%s' of length %s occurs %s or more times"%(seq,n,times)

 

 

  Comments,     Trackbacks

Shedding New Light on Tor-Based Malware

Alarm bells went off last August when spikes in Tor client downloads were traced to a large click-fraud and Bitcoin-mining botnet called Sefnit.

The malware was using the popular anonymity network to communicate with hackers in order to transmit stolen data and receive additional commands. In Sefnit’s case, the 600 percent increase in Tor usage it kicked off was also its downfall as Tor administrators noticed performance issues and steps were taken to strangle its activity.

Hackers’ use of Tor and other Darknet services is really nothing new, but incidents such as the Sefnit takedown that ensued as well as the disruption of the Silk Road drug and malware underground market that also operated over Tor shed more light on the practice.

For example, researchers have Kaspersky Lab have published research uncovering three different campaigns that use Tor as a host infrastructure for criminal malware activities: a 64-bit version of the Zeus Trojan that sends traffic through Tor and creates Tor hidden services to obscure the hackers’ location; Chewbacca, a Trojan that steals data from memory a la ram scapers, and communicates over Tor; and most recently an Android Trojan that uses a .onion domain as a command and control infrastructure.

Researcher Sergey Lozhkin, a senior researcher with Kaspersky Lab, said his work investigating criminals’ use of darknets turned up 900 Tor hidden services and 5,500 nodes.

“The possibility of creating an anonymous and abuse-free underground forum, market or malware C&C server is attracting more and more criminals to the Tor network,” Lozhkin said. “Hosting C&C servers in Tor makes them harder to identify, blacklist or eliminate.”

Lozhkin said Tor underground markets aren’t set up much differently than legitimate ecommerce sites; most include some sort of registration process, offer buyers ratings on traders, and familiar interfaces through which purchases are made. Criminals are selling everything from money laundering services, credit cards, skimmers, carding equipment and more. And most of it is sold using Bitcoin.

Yesterday, Microsoft published new details on Sefnit’s Tor components and configuration data, the domains it was in contact with and how it communicates over Tor.

After the August spike in Tor traffic alerted experts, Microsoft took steps to stop the botnet that were finally realized last Oct. 27 when it modified signatures sent through its update services that removed the outdated Tor client service installed by the malware. The Tor client service had a specific configuration that Microsoft identified, and despite some concerns that Microsoft was overstepping by possibly snaring some versions of Tor legitimately installed by users, the cleanup moved forward and Sefnit numbers dwindled.

The version installed with Sefnit was v0.2.3.25 and it did not automatically update, Microsoft said, leaving users exposed to a number of exploitable vulnerabilities. The Tor client was added as a Windows service on every computer infected by Sefnit and was configured to accept connections over ports 9050 and 9051; 9051 was used by Sefnit to obtain status information regarding its connection to Tor, while 9050 was used as a communication point for the malware’s SOCKS proxy. Any application configured to use a proxy server, Microsoft said, to communicate over Tor. Sefnit, Microsoft said, used this port to contact its command servers and bypass intrusion detection systems, and utilized Tor hidden services to obfuscate server locations.

The malware comes with a list of .onion domains that are drop points for stolen data. Microsoft said the list of C&C servers was found in file inside a random directory that is cryptographically generated. Within that directory is a file with a .ct extension that contains the victim’s IP address, a string that is likely a victim ID, a list of command and control domains, and a working directory of the malware, Microsoft said.

Microsoft said that at its peak in August 2013 there were an estimated four million Sefnit clients which began receiving commands; that number had dipped significantly by the end of December, leaving two million that could still be at risk for attack because of Sefnit-added Tor services that are outdated, Microsoft said.

 

 

'악성코드 소식' 카테고리의 다른 글

ghost, gh0st 관련 정보  (1) 2013.09.17
Targeted ‘phone ring flooding’  (0) 2013.02.14
Red October  (0) 2013.01.16
Ole Trade Tool 악성코드  (0) 2010.12.13
Koobface 새로운 버젼입니다~  (0) 2010.10.28
  Comments,     Trackbacks

파이썬 팁 모음

http://coreapython.hosting.paran.com/etc/Python%20Tips,%20Tricks,%20and%20Hacks.htm


나중에 또 볼일이 있겠네요~

  Comments,     Trackbacks

Naming is analysis and research

이름을 지었다는 것은 그 대상에 대해 이미 어느정도 연구와 분석이 이루어졌다는 뜻.

가장 적합한 이름을 만들었다는 것은 대상에 대한 가장 정확한 의미를 포함시켰다는 뜻 같다.


그래서 이름을 짓는 것은 대충할 수 없고 매우 중요한 일 이라고 생각한다.

이름을 짓는 행위 자체도 분석과 연구다.

  Comments,     Trackbacks