Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: cl.exe build active file",
"label": "Build win-witr.exe",
"command": "cl.exe",
"args": [
"/Zi",
"/O2",
"/std:c++20",
"/EHsc",
"/nologo",
"/std:c++20",
"/Fe${fileDirname}\\${fileBasenameNoExtension}.exe",
"${file}"
"main.cpp",
"/DUNICODE",
"/D_UNICODE",
"/Fe:win-witr.exe"
],
"options": {
"cwd": "${fileDirname}"
Expand Down
43 changes: 33 additions & 10 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1745,7 +1745,8 @@ void FindProcessPorts(DWORD targetPid) {



void PIDinspect(const std::vector<DWORD>& pids, const std::vector<std::string>& names, HANDLE hshot) { // ooh guys look i'm in the void
void PIDinspect(const std::vector<DWORD>& pids, const std::vector<std::string>& names, HANDLE hshot, std::vector<bool>& statuses, int related, ) {
//^^^ ooh guys look i'm in the void
DWORD pid = pids[0];
std::unordered_map<DWORD, PROCESSENTRY32> pidMap;
PROCESSENTRY32 pe32{};
Expand Down Expand Up @@ -2067,23 +2068,45 @@ ProcInfos findMyProc(const char *procname, HANDLE hSnapshot) {
}
// The above function is taken from https://cocomelonc.github.io/pentest/2021/09/29/findmyprocess.html, modified simply to use WideToString for the process name comparison among other things.
// Thanks!

std::vector<std::string> normalizeArgs (std::vector<std::string>& args) {
// flags could be -, --, or /. heck,
for i in args.size() {
if (args.[i].at(0) == "/") {
args[i].erase(0, 1); } else {
if (args[i].at(0) == "-") {
if (args[i].at(1) == "-") // i could've done stats_with ("--") too but i feel like it takes more performance
// all this arg stuff probably steals milliseconds unfortunately
{
args[i].erase(0, 2);
} else {
args[i].erase(0, 1);
}
}
}


}



int main(int argc, char* argv[]) {
SetConsoleOutputCP(CP_UTF8);
virtualTerminalEnabled = IsVirtualTerminalModeEnabled();
for (int i = 0; i < argc; ++i) {
std::string arg = argv[i];
std::vector<std::string> arguments(argv, argv + argc);
for (size_t i = 0; i < arguments.size(); ++i) {
std::vector<std::string> args = normalizeArgs(arguments);



if (i == 0 && argc > 1) {
if (i == 0 && args.size() > 1) {
continue;
}




if (argc == 1 || std::string(argv[1]) == "-h" || std::string(argv[1]) == "--help") {
if (args.size() == 1 || args[1] == "h" || args[1] == "help") {
if (!forkAuthor.empty()) {
std::cout << "\nwin-witr - Why is this running? Windows version by supervoidcoder. Fork by " << forkAuthor << std::endl;
} else {
Expand Down Expand Up @@ -2124,15 +2147,15 @@ int main(int argc, char* argv[]) {
}


if (arg == "-v" || arg == "--version") {
if (args[2] == "v" || args[2] == "version") {
std::cout << "\nwin-witr " << version << std::endl;
return 0;
}

if (arg == "--pid") {
if (i + 1 < argc) {
if (args[2] == "pid") {
if (i + 1 < args.size()) {

std::string pidStr = argv[i + 1]; // never increment the actual variable unless you're actually trying to find the next argument, otherwise
std::string pidStr = args[i + 1]; // never increment the actual variable unless you're actually trying to find the next argument, otherwise
// skipping arguments will happen and can crash if there is, in fact, no next argument.

int pid = 0;
Expand Down Expand Up @@ -2187,7 +2210,7 @@ int main(int argc, char* argv[]) {
return 0;
}
// check for process name if no recognized flags
else if (arg[0] != '-') { // if it doesn't start with -- or -
else {
std::string procName = arg;
HANDLE hshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (INVALID_HANDLE_VALUE == hshot) {return 1;}
Expand Down
Loading