Jump to content

[Version 1] Basic Open Terminal And Run A Command


Seshan
 Share

Recommended Posts

This should open Spot Light It's uses CMD+Space, but since spot lights command can easily be changed or you can even disable spot light all together it may not work.

What it does:

Blinks once when starting the code

Quits any popup that pops up

Opens spot light

Searches and opens terminal

Pings google (this can be changed to what ever you want it to do

CTRL+C to stop anything running

Quits terminal

Blinks twice when it finishes running.

int ledPin = 11;

void setup() {
  pinMode(ledPin, OUTPUT);
}
void loop() {
  delay(8000);
  //LED blinks when code starts
  digitalWrite(ledPin, HIGH);
  delay (1000);
  digitalWrite(ledPin, LOW);
  // Command key
  Keyboard.set_modifier(MODIFIERKEY_GUI);
  Keyboard.send_now();
  // Command key + Q to quit any pop ups
  Keyboard.set_key1(KEY_Q);
  Keyboard.send_now();
  // releases Q key
  Keyboard.set_key1(0);
  Keyboard.send_now();
  // delay
  delay(500);
  // open spotlight
  Keyboard.set_key1(KEY_SPACE);
  Keyboard.send_now();
  // releases keys
  Keyboard.set_modifier(0);
  Keyboard.set_key1(0);
  Keyboard.send_now();
  // open terminal
  Keyboard.print("terminal.app");
  // delay
  delay(50);
  Keyboard.set_key1(KEY_ENTER);
  Keyboard.send_now();
  Keyboard.set_key1(0);
  Keyboard.send_now();
  // delay for termianl to load
  delay(4000);
  // enters someothing in terminal
  Keyboard.print("ping www.google.ca");
  delay(50);
  Keyboard.set_key1(KEY_ENTER);
  Keyboard.send_now();
  Keyboard.set_key1(0);
  Keyboard.send_now();
  //time for command to run
  delay(9000);
  //stops commands
  Keyboard.set_modifier(MODIFIERKEY_CTRL);
  Keyboard.send_now();
  Keyboard.set_key1(KEY_C);
  Keyboard.send_now();
  Keyboard.set_key1(0);
  Keyboard.set_modifier(0);
  Keyboard.send_now();
  //quits terminal
  Keyboard.set_modifier(MODIFIERKEY_GUI);
  Keyboard.send_now();
  Keyboard.set_key1(KEY_Q);
  Keyboard.send_now();
  Keyboard.set_key1(0);
  Keyboard.send_now();
  delay(200);
  //led blinks twice when code ends
digitalWrite(ledPin, HIGH);
  delay (1000);
  digitalWrite(ledPin, LOW);
  delay (1000);
  digitalWrite(ledPin, HIGH);
  delay (1000);
  digitalWrite(ledPin, LOW);

  delay(900000);
}

Edited by Seshan
Link to comment
Share on other sites

This way does work and will work on a lot of Mac's, but will encounter some issues.

Example, I just ran it, and instead of running Terminal it ran a program I have called "Terminal Emulator" which will not run the commands, just something to bare in mind.

But cool none the less.

Link to comment
Share on other sites

Suggestion: What you type in Terminal should be "somecommand -with -some args && killall Terminal" to kill the terminal once the payload completes. This won't work for constant payloads such as ping, however most payloads will be quick, not something which stays running forever.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...