DAY53
DAY53

서버관리하기


.92번 데이터를 .94로 백업되도록 설정

backup.sh
	#!/bin/sh
	set $(date)
	fname="92backup-home$1$2$3.tar.gz"
	tar cvzf ./jyb/$fname /home/jyb/public_html
	tar cvzf 저장위치 저장내용위치

tar 예외처리
backup.sh 수정
#!/bin/sh
set $(date)
fname="backup-92home$1$2$3.tar.gz"
tar cvzf /home/이니셜/public_html/(백업 폴더)/$fname --exclude=/home/이니셜/public_html/(백업 폴더) /home/이니셜/public_html

rsync.sh작성
	#!/bin/sh
	rsync -avz ./jyb 192.168.0.94::ip92

ip92는
.94의
/etc/rsync.conf에서 확인

#--exclude-from=/etc/rsync_exclude.lst 제외 옵션이므로 제거

.sh파일에 777로 권한 부여후 ./로 실행

/etc/crontab
	10 04   * * *   root    /home/jyb/backup.sh
	10 04   * * *   root    /home/jyb/rsync.sh

systemctl restart cron


Bootstrap Example

p7.exe를 분석하여 비밀번호를 알지 못하더라도 결과값을 보도록 해보자


vmware
conda activate py27
virtualbox
host network manger 삭제 후 생성

cuckoo -d
cuckoo web -H 192.168.0.188

[p7.exe]

#include 

int	hidden_value = 0xdeadf00d;
int main (void) {
	int a,b,c, value;
	char buf[100];
	printf("Input password:");
	gets(buf);
	if (strncmp(buf, "reversing", 9) !=0) {
		printf("Invalid password");
		return -1;
	}
	printf("Hidden value: 0x%x\n", hidden_value);
	return 0;
}

=> 암호는 reversing

분기점 이해하기

1. 플래그 직접 수정

f2 > 0040153D, 00401542, 00401573
f4 > 클릭한 위치로 이동
f8 > 한칸씩 이동

ctrl g > 0040402B (hidden 문자열 확인)


ZF이해하기
if (strncmp(buf, "reversing", 9) !=0) {
	printf("Invalid password");
	return -1;
}

=> 입력한 값과 "" 문자열이 같으면 0 ( 맞추면 0 )
0과 같지 않아야 Invalid password 뜬다

ZF = 1 > 입력값과 문자열 일치
ZF = 0 > 초기화

입력값과 문자열 값이 일치하면 ZF=0 에서 ZF=1로 변경되는 것을 확인할 수 있다

hidden_value=XXXXXX


if (strncmp(buf, "reversing", 9) !=0) {
	printf("Invalid password");
	return -1;
}

=> 입력한 값과 "" 문자열이 같으면 0 ( 맞추면 0 )
0과 같지 않아야 Invalid password 뜬다

==> 따라서 첫 분기점에서 ZF를 1로 직접 변경(클릭)하면 일치하지 않아도 hidden value를 볼 수 있다.



#명령어 정리(항상 머리속에 스택 구조가 있어야함)
mov eax, ebx	EBX 레지스터 내의 값을 EAX 레지스터로 복사
lea eax,[ebx+8]	EBX+8을 EAX에 저장함
test eax,eax두 개의 오퍼랜드를 비교(AND 연산을 수행해보고 플래그를 설정함)
leave 함수에서 사용한 지역변수 스택을 비움
ret 스택에 저장된 주소로 복귀
jmp address 무조건 해당 주소로 옮겨감

#단축키 암기 58p.


Bootstrap Example

어셈블리 입문에 도움이 되는 pep/8 가상머신 이해하기


장점: 가상머신의 구조가 더 단순하므로 컴퓨터 구조의 이해에 도움
단점: 실제로 활용이 어려움

다운로드
https://computersystemsbook.com/4th-edition/pep8/
download windows

참고서적
컴퓨터 구조(프로그래밍 관점에서 바라보는)

pep8 실행

object code - untitled.pepo
51 00 07 51 00 08 00 48 69 zz

build > run object
=> hi 확인

source code - untitled.pep
;File: fig0510.pep
;Computer Systems, Fourth Edition
;Figure 5.10
;
         CHARO   'H',i       ;Output 'H'
         CHARO   'i',i       ;Output 'i'
         STOP                
         .END
=> object code - untitled.pepo
51 00 07 51 00 08 00 48 69 zz

=> Assembler Listing - untitled.pepl

      Object
Addr  code   Symbol   Mnemon  Operand     Comment
             ;File: fig0510.pep
             ;Computer Systems, Fourth Edition
             ;Figure 5.10
             ;
0000  500048          CHARO   'H',i       ;Output 'H'
0003  500069          CHARO   'i',i       ;Output 'i'
0006  00              STOP                
0007                  .END                  

=> Memory Dump
0000 | 50 00 48 50 00 69 00 48 |P.HP.i.H
0008 | 69 00 00 00 00 00 00 00 |i.......



명령어코드 이해하기
- 명령어코드(OP-Code)
- 오퍼랜드

컴퓨터 주소처리 방식
- 직접주소방식
- 간접주소방식

명령어 처리 절차
1. EIP 주소 접근하여 Op-code 부분(1바이트) 가져옴
1바이트 = 8비트

FIFO
RLU
LIFO
HIP


2. Op-code를 해석함 Op-code 명령어 길이만큼 EIP 주소 변경

3. Operand(오퍼랜드) 부분 읽어옴

4. Op-code에 따라 명령어 실행

5. 실행 결과를 레지스터에 저장

6. 다음 EIP 주소에 접근


cheat engine이란?

제목


About Cheat Engine

Cheat Engine is a tool designed to help you with modifying single player games without internet connection so you can make them harder or easier depending on your preference(e.g: Find that 100hp is too easy, try playing a game with a max of 1 HP), but also contains other usefull tools to help debugging games and even normal applications, and helps you protect your system by letting you inspect memory modifications by backdoors and even contains some ways to unhide them from conventional means.

It comes with a memory scanner to quickly scan for variables used within a game and allow you to change them, but it also comes with a debugger, disassembler, assembler, speedhack, trainer maker, direct 3D manipulation tools, system inspection tools and more which are also useful for normal programmers and software analysts.

Besides these tools it also comes with extensive scripting support which will allow experienced developers to create their own applications with ease and share them with other people



Bootstrap Example

최종 프로젝트 구상하기


336p. 트로이목마 만들기 프로젝트


	AllowOverride All
	Require all granted
	Options None


3. writable 권한 바꾸기
chmod -R 777 writable (권한변경)

4. a2enmod rewrite

5. cd /home/ci4/public_html
	cp env .env
	nano .env
	CI_ENVIRONMENT = development (개발자모드 변경) <->production (?)
	에러 뜨면 이유를 알려줌

dns확인
netplan
sudo netplan apply

sudo apt update
sudo apt install php-intl php-mbstring

MessageRelayServer.py

from packet import Packet

class RelayServer:
runVirus : 5715
runClient : 7270

Victim : runVirus -> 5715
Client : Hacker -> 7270



.ova
중계서버 만들기
아나콘다 설치