반응형
http://skypher.com/wiki/index.php/Hacking/Shellcode/GetPC

GetPC (get Program Counter, also known as GetEIP on x86) code is code that determines its own location in a process' address space. It is commonly used in code that needs to reference itself, for instance in self-decoding and self-modifying code.

CALL GetPC

The easiest way to implement GetPC code on x86 is using the CALL instruction, like so:

$+0: E8 00000000 CALL $+5  ; PUSH $+5 onto the stack $+5: 59 POP ECX  ; ECX = $+5 $+6: ...shellcode...

Because the argument to the CALL instruction is the offset of the code to call, in this case 0, this code contains null bytes. Unfortunately, it is often not possible or practical to inject null bytes into a target process during exploitation. A common trick to get around this is to make the CALL point to a lower address address, making the offset negative, like so:

$+0     EB XX       JMP     SHORT $+N   ; Jump to the call instruction
$+5:    59          POP     ECX         ; ECX = $+N+5
$+6:    ...shellcode...
$+N:    E8 FFFFFFXX CALL    $+5         ; PUSH $+N+5 onto the stack and jump back to $+5

As you can see, this code is null free but this code has two drawbacks:

  1. It is 2 bytes larger than the first example.
  2. The shellcode between the POP and CALL instruction can only be 126 bytes, if you need more room, you will have to jump over the call and put the remainder after it.

There is a second trick to get around these two problems:

$+0 EB FFFFFFFF CALL $+4  ; PUSH $+5 onto the stack and jump to $+4 $+5: C8 59XX XX ENTER XX59,XX  ; Does not get executed like this; see below.

When this code executes, the CALL will jump to the last byte of its own instruction. The code executed after the CALL will therefore be:

$+4: FFC8 DEC ECX  ; Does nothing useful; can be considered a NOP. $+6: 59 POP ECX  ; ECX = $+5 $+7: ...shellcode...

The above code is only 1 byte larger than the first GetPC and puts no constraints of the shellcode following it.

FSTENV GetPC

[todo:References]

A way to retrieve the value of EIP on x86 systems is to use the x87 FSTENV instruction to store the state of the x87 floating point chip after issuing a FLDZ instruction. The structure store in memory by FSTENV will then contain the address of the FLDZ instruction at offset 0x0C of the structure:

$+0 D9EE FLDZ  ; Floating point stores $+0 in its environment $+2 D974E4 F4 FSTENV SS:[ESP-0xC]  ; Save environment at ESP-0xC; now [ESP] = $+0 $+6 59 POP ECX  ; ECX = $+0

This method is also null free and uses the same amount of bytes as the last CALL example.

SEH GetPC

[todo:References]

A third way to write GetPC code is to use the Windows specific Structure Exception Handler (SEH). When an exception happens in a process on Windows, a structured exception is created by the operating system and passed to the first SEH handler to see if it can handle it. If not, the second SEH handler is asked, etc... if no SEH handler handles the exception, the program is terminated because of an unhandled exception. Whenever a structure exception handler is called, it is passed (pointers to) information about the exception on the stack. This information includes the address in memory of the instruction that caused the exception.

It is relatively simple to register a structured exception handler with the OS. If a shellcode can generate a small structured exception handler at a known location in memory and register it before causing an exception, this small structured exception handler would get executed. It could determine the address of the instruction that caused the exception and jump back to the next instruction (the one immediately following it). The code would then continue as normal, only now knowing exactly where it is.[todo:Write an example]

Because the SEH was abused heavily by exploits for various purposes, Microsoft has introduced additional checks on the SEH as mitigation against this abuse with each service pack of Windows XP. These have made writing working SEH GetPC increasingly harder. On Windows Vista, it seems these mitigation make it impractical of not impossible to write working SEH GetPC code. However, it is still possible to write SEH GetPC code on Windows XP sp3. It's even possible to do so using only alphanumeric instructions, which is used in ALPHA3 to create alphanumeric SEH GetPC code.



반응형

'작업공간 > Security' 카테고리의 다른 글

Port Scan  (0) 2012.02.16
디렉토리 리스팅으로 발견한 페이지  (1) 2012.02.09
Snort 룰 설명  (0) 2012.01.31
SQL 인젝션 취약점  (5) 2012.01.26
패킷에서 파일 추출하기 - 2  (2) 2011.12.29
반응형
반응형

'작업공간 > Security' 카테고리의 다른 글

디렉토리 리스팅으로 발견한 페이지  (1) 2012.02.09
[펌]GetPC  (0) 2012.02.06
SQL 인젝션 취약점  (5) 2012.01.26
패킷에서 파일 추출하기 - 2  (2) 2011.12.29
Unpack  (0) 2011.12.29
반응형
특정 솔루션에 한해서 먹히긴하지만.......
SQL 인젝션.. 이라고 말하기도 부끄럽다..
아직도 이런게 먹힐 줄이야..

URI에 ' 도 없이 SQL 쿼리를 날렸는데.. 먹히네..

select * from usr

하하..

정리 좀 하고.. 나중에 공개~
우연하게 얻어걸리긴했지만.. 취약점 연구는 재밌는 것~
반응형

'작업공간 > Security' 카테고리의 다른 글

[펌]GetPC  (0) 2012.02.06
Snort 룰 설명  (0) 2012.01.31
패킷에서 파일 추출하기 - 2  (2) 2011.12.29
Unpack  (0) 2011.12.29
Memory String  (0) 2011.12.29
반응형
작년 1월 경, 휘슬 패턴을 추출한적이 있습니다.
지인이 해보라고 해서.. 했던거고.. 그땐 그걸 어떤식으로 사용할 수 있을지를 몰랐더랬죠..
1년이 지난 얼마전에 다시 한번 휘슬 패턴을 추출하였습니다.
역시.. 이번 추출도 공부 목적!!
(단, 저번에는 뚫는데 목적이 있었으나.. 이번엔 웹쉘 탐지패턴을 이해하고자 하는 바램에서.. ^^;)

근데 저번이랑 똑같은 프로그램인데도.. 작년이랑 틀리게.. 너무 쉽게 풀어버렸습니다;;
작년엔 왜 코드의 흐름을 그렇게 생각했을까요? ^^;;

암튼.. 아래가 휘슬 패턴의 일부분 입니다.


너무 작나요? ^^; 클릭하면 크게 보일지도 모르겠네요..

좌측이 작년버전.. 우측이 얼마전에 추출한 버전입니다.
뭔가 이상한게 보이시나요?

네. 패턴 넘버는 똑같은데 패턴이 조금 변경된 것들이 다수 있네요.
네. 패턴이 삭제된 것들이 있네요.
네. 패턴이 추가된 것들이 있네요.

홈페이지에도 패턴 업데이트 관련 공지사항이 없어 언제 업데이트가 된건진 모르겠으나..
업데이트가 되고있고
업데이트 시, 패턴 파일 전체가 업데이트 되는 듯 싶으며..
꾸준히 관리하면서 오탐나는 패턴은 수정/삭제가 이루어지는 듯한 모습이네요.

올해 추출한 패턴은 1144개.
구체적으로 추가/변경/삭제 된 패턴은 비교분석해봐야 알겠지만.. 이 또한 공부가 많이 되겠네요 ^^


반응형
반응형
저번에는 수작업을 통해 파일을 추출하는 방식을 썼었습니다..
근데 알고보니.. 그 기능은 이미 Wireshark에서 지원되는 있는 기능이더라고요..

그래서 오늘은 간략하게 Wirtrshark로 파일을 추출하는 것을 써볼까 합니다.

일단 Wireshark로 cap파일을 Open 합니다.
이후 아래 그림처럼 File -> Export -> Objects -> HTTP 선택합니다.


선택하면 아래와 같은 창이 뜨는데 원하는 파일을 선택하고 우측 하단에 Save As 를 클릭하시면 됩니다.


어때요~ 쉽죠? ^^;




반응형

'작업공간 > Security' 카테고리의 다른 글

Snort 룰 설명  (0) 2012.01.31
SQL 인젝션 취약점  (5) 2012.01.26
Unpack  (0) 2011.12.29
Memory String  (0) 2011.12.29
AET  (0) 2011.10.31
반응형
마땅한 샘플을 못찾아서..
글로만 설명하는 아주 지루한 시간이 되겠습니다.

저도 잘 못풀긴 하지만..
디버거를 자주 사용하지 않았던.. 사람들은 저보고 어떻게 푸냐고 묻습니다.

제가 푸는 방식은.. 순전히 제 경험에 의해 만들어진 것이기 때문에.. 설명드리기가 생각보다 쉽지 않습니다.
설명을 못한다는 것은 결과적으로 제가 모르는 것이기 때문에 다른 사람에게 설명을 할 수 있게끔 고민을 했었고..
그 방법을 설명을 해줬으나.. 제가 너무 어렵게 이야기 하는건지..
물어봤던 사람들이 디버깅에 관심이 없어서 못하는건지.. 다들 못하시더라고요 ^^;

일단!! 제가 설명해주는 Unpack을 하기 위해선.. 몇가지 선지식이 있어야 합니다.
1. Unpack 이란?
2. Unpack 원리
3. 일반적인 Stratup Code

이 정도 알면 많은 악성코드들을 Unpack 할 수 있을거 같네요. (그..그렇게 많이는 아닐지도요 ^^;)

방법은 아주 간단합니다.
1. OllyDBG 로 샘플을 Open 한다.
2. bp ExitProcess 또는 적절하게 코드가 다 풀릴때까지 실행한다.
3. 압축이 풀린 코드영역에서 일반적인 Startup Code에 자주 쓰이는 API를 검색한다.
4. Startup Code이기 때문에 그곳이 바로 Startup Function이며, 가장 상위에 있는 코드가 OEP일 것이다.

나머지는.. 심슨아저씨(Import REC)에게 부탁을 하거나 수작업으로 슥슥.. 처리해주시면 됩니다.

이 방식은.. 압축을 어떤 방식으로 했는지는 전혀 관계가 없는 방식입니다.
Unpack 코드를 확인하지 않기 때문에 어느정도 Hole 이 있는 방식이긴합니다.

하지만.. 쉽기 때문에.. 약간의 지식만 있다면 누구나 다 할 수 있는 방식이라고 생각하는데.. 아닌가요? ^^;




반응형

'작업공간 > Security' 카테고리의 다른 글

SQL 인젝션 취약점  (5) 2012.01.26
패킷에서 파일 추출하기 - 2  (2) 2011.12.29
Memory String  (0) 2011.12.29
AET  (0) 2011.10.31
TOP 100 Shells  (0) 2011.07.06
반응형
기본 정보를 수집할 때, 일반 String 보다는 아무래도 Memory String을 보는게 도움이 되는 경우가 많다.
일반적으로 프로세스가 떠 있을 경우, Sysinternals Tool을 이용하면 쉽게 덤프를 생성할 수 있다.

하지만!! 프로세스가 죽고 다른 프로세스에 Injectoin 될 경우, 찾는데 어려움을 겪을 수 있다.

곰곰히 생각해보면 프로세스가 죽기전에 Memory dump를 생성하고 String을 확인하면 될 것 같다.
프로세스를 제어하기 위해 디버거를 사용하면 비교적 쉽게 진행 할 수 있다.


OllyDBG를 다운 받은 이후, commandbar 플러그인을 설치하면 위 그림과 같이 입력할 수 있는 창이 생성된다.

이때 bp ExitProcess 라고 치고 엔터!!
 - bp = BreakPoint, 특정 부분에서 멈추고 싶을 때 사용한다.
 - ExitProcess = 프로세스가 종료 될 때, 사용되는 API

위 명령의 뜻은 "프로세스가 종료되기 전, 종료 루틴을 실행할 때 멈춰라!!" 라는 의미다.
저렇게 해놓고 실행(F9) 시키면 해당 프로세스가 종료되기 전에 멈추게 되며,
OllyDBG나 Sysinternals Tool을 이용하여 dump를 생성하면 된다.

초간단!!


반응형

'작업공간 > Security' 카테고리의 다른 글

패킷에서 파일 추출하기 - 2  (2) 2011.12.29
Unpack  (0) 2011.12.29
AET  (0) 2011.10.31
TOP 100 Shells  (0) 2011.07.06
코어덤프 확인 및 생성방법  (2) 2011.06.20
반응형
区段
====
.text 代码段,可以被读取,可以被执行
.rdata 存放只读数据(字符串字面值,常量以及调试目录信息)
.data 数据区段除了上面的static变量,还有存储在堆栈段的自动变量,其他所有变量都在.data里,典型的有各类全局变量
.idata 输入的dll函数信息
.edata 输出函数用的
.rsrc 文件资源节
.reloc 重定位区段(基址重定位表)
.mackt 是Import Reconstructor修复输入表时候添加的节

http://xdarkr.blog.163.com/blog/static/1681157042010730104421511/

반응형

'작업공간 > 기본적인 삽질 & 기록' 카테고리의 다른 글

구글 봇탐지 기술..?  (0) 2012.02.12
휘슬(WHISTL) 2탄~  (4) 2012.01.09
중국어 번역. RAT  (0) 2011.12.06
部分ADSL路由器默认帐号密码  (0) 2011.12.05
[펌]Reverse Shell Cheat Sheet  (0) 2011.09.28
반응형
波尔远程控制
被控端 주인    
生成被控端 호스트 생성
置默被控端图标 기본 호스트 아이콘 설정
动连接被控端 수동 호스트 연결
批量更新被控端 일괄 호스트 업데이트
更新被控端接地址 업데이트 호스트 연결 주소
(重新接) 연결 끊기 (다시 연결)
关闭被控端 호스트 종료
卸載被控端 호스트 제거
筛选 필터
磁盘 디스크    
文件管理 디스크 파일 관리
络计算机 네트워크 컴퓨터
화면    
实时操作 화면 실시간 운영
자동 스크린샷
播放 애니메이션
停止播放 재생 중지
播放所有被控端 모든 호스트에 대해 애니메이션 반복
送全屏画 전체화면 보내기
关闭屏画 전체화면 닫기
체계    
程管理器 프로세스 관리
编辑 레지스트리 편집기
系统管理 서비스 관리 시스템
行DOS命令 DOS 명령 실행
注销 끄기 (로그아웃)
重新启动 다시 시작
关闭计算机 컴퓨터 종료
系统信息 시스템 정보
窗口    
前窗口列表 현재 윈도우 목록
页浏览历录 (비활성화) 기록된 웹 검색 기록
URL 열기
기타    
操作所有被控端 모든 호스트에 대한 작업
摄像头监控 감시카메라
风监听 (BETA) 마이크 모니터링
信息框 정보 상자
播放WAV MID WAV 방송
停止音乐播放 음악 플레이 중지
出光 CD-ROM 열기
关闭 CD-ROM 닫기
程序 프로그램    
设置主机各标识 로고의 호스트를 설정합니다
分组设置 그룹 설정
系统设 시스템 설정
动态域名 동적 도메인네임 (DDNS)
FTP自动更新IP FTP 자동업데이트 IP
接代理服 프록시 서버 연결
重新启动 서비스 재시작
本机被控端检测 로컬 호스트 탐지
看操作日志 작업 로그 확인
置主界面皮 주 인터페이스 스킨
置透明度 설정 투명성
访问 제작 웹사이트 방문
도움
演示和常见问题 애니메이션 및 FAQ
등록
更新 업데이트 확인
프로그램 정보
반응형
반응형
艾玛 701g
192.168.101.1 192.168.0.1
用户名:admin 密码:admin
用户名:SZIM 密码:SZIM
艾玛701H
192.168.1.1 10.0.0.2
用户名:admin 密码:epicrouter
home gateway
路由的IP是:10.0.0.2
管理名:admin 密:epicrouter
实达2110EH ROUTER
192.168.10.1
用户名:user 密码:password
用户名:root 密码:grouter
神州数码/华硕:
用户名:adsl 密码:adsl1234
全向:
用户名:root 密码:root
普天:
用户名:admin 密码:dare
e-tek
用户名:admin 密码:12345
zyxel
用户名:anonymous 密码:1234
北电
用户名:anonymous 密码:12345
大恒
用户名:admin 密码:admin
大唐
用户名:admin 密码:1234
斯威特
用户名:root 密码:root
用户名:user 密码:user

中兴
用户名:adsl 密码:adsl831
(中兴的adsl的密码前面为adsl,后面为型号,比如中兴831,密码就是adsl831)
磊科2505+NR
用户名:guest 密码:guest
友讯D-link DI504 DI604
用户名:admin 没有密码
1、全向QL1680
IP地址10.0.0.2,用户名:admin,密码:qxcomm1680,管理员密码:qxcommsupport。全向
QL1880 IP地址192.168.1.1,用户名:root,密码:root 全向QL1688
IP地址10.0.0.2,用户名为admin;密码为qxcomm1688
2、TP-LINK TD-8800在IE输入192.168.1.1,户名admin,密码admin
3、合勤zyxel 642 在运行输入telnet 192.168.1.1 密码1234
4、Ecom ED-802EG 在IE输入192.168.1.1,用户名和密码都为root
5、神州数码6010RA,在IE输入192.168.1.1 用户名为ADSL,密码为ADSL1234
6、华为SmartAX
MT800的初始IP是192.168.1.1,用户名和密码都为ADMIN,恢复默认配置的方法有两种,一种是连续按MODEM背后的RESET键三次,另一种是在配置菜单的SAVE&REBOOT里选择恢复默认配置。

7、伊泰克:IP:192.168.1.1 用户名:supervisor 密码:12345
8、华硕IP:192.168.1.1 用户名:adsl 密码:adsl1234
9、阿尔卡特 192.168.1.1 一般没有密码
10、同维DSL699E 192.168.1.1 用户名:ROOT 密码:ROOT
11、大亚DB102 192.168.1.1 用户名:admin 密码:dare
高级设置://192.168.1.1/doc/index1.htm
12、WST的RT1080 192.168.0.1 username:root password:root
13、WST的ART18CX 10.0.0.2 username:admin password:conexant
username:user
password:password
14、实达V3.2 root root V5.4 root grouter
15、泛德 admin conexant
16、东信Ea700 192.168.1.1用户名:空 密码:password
17、broadmax的hsa300a 192.168.0.1 username:broadmax
password:broadmax
18、长虹ch-500E 192.168.1.1 username:root password:root
19、重庆普天CP ADSL03 192.168.1.1 username:root password:root
20、台湾突破EA110 RS232:38400 192.168.7.1 usernameSL pswSL
21、etek-td的ADSL_T07L006.0 192.168.1.1 User Name: supervisor
Password: 12345 忘记密码的解决办法:
使用超级终端的Xmodem方式重写Vxworks.dlf,密码恢复成:12345
22、GVC的DSL-802E/R3A 10.0.0.2 username:admin
password:epicrouter username:user
password:password
23、科迈易通km300A-1 192.168.1.1 username: password:password
科迈易通km300A-G 192.168.1.1
username:root password:root 科迈易通km300A-A 192.168.1.1
username:root or admin
password:123456
24、sunrise的SR-DSL-AE 192.168.1.1 username:admin password:0000
sunrise的DSL-802E_R3A 10.0.0.2 username:admin
password:epicrouter username:user
password:password
25、UTStar的ut-300R 192.168.1.1 username:root or admin
password:utstar
반응형

'작업공간 > 기본적인 삽질 & 기록' 카테고리의 다른 글

[펌] 常见区段 (일반섹션? 섹션 정보)  (4) 2011.12.06
중국어 번역. RAT  (0) 2011.12.06
[펌]Reverse Shell Cheat Sheet  (0) 2011.09.28
Compilation of wordlist downloads  (0) 2011.02.10
윈도우 DLL  (0) 2011.02.09

+ Recent posts