Jump to content

[Version 1] [code][os X][windows] Automatic Twitter Poster


Recommended Posts

This will automatically post to twitter. User has to be logged in. I'll be adding it to the wiki ( http://www.hak5.org/projects/doku.php?id=usb_rubber_ducky )

Windows Code

http://drp.ly/Vca2f

// Automatic twitter poster for Windows, User must be logged into twitter for this to work.
// Created by Seshan 30/04/10 11:48 PM

int ledPin = 11;


void setup() {
  
  pinMode(ledPin, OUTPUT); // put this before other led commands or the LED will be dim
  
  ledstart();     // lights up when connected
  delay(3000);   // delay for computer
  ledstart();  // lights up when payload starts
  // opens run
  Keyboard.set_modifier(MODIFIERKEY_GUI);
  Keyboard.send_now();
  Keyboard.set_key1(KEY_R);
  Keyboard.send_now();
  d(); // this is a 100ms delay, see below for commands.
  Keyboard.print("www.twitter.com"); // goes to twitter
  d();
  enter(); 
  delay(6000); // delay for browser to load
  Keyboard.print("This is a test"); // this is what gets posted to twitter, change this to what ever you want
  d();
  Keyboard.set_key2(KEY_TAB);
  Keyboard.send_now();
  enter();
  Keyboard.set_key2(0);
  ledend();
  
  // delay to stop it running again, 9000!!! milli-sec.
  delay(9000);
}
  
  
void loop() {

}
// hits enter
void enter(){
  
  Keyboard.set_key1(KEY_ENTER);
  Keyboard.send_now();
  Keyboard.set_key1(0);
  Keyboard.send_now();
  
}

// LED command for end of script.
void ledend(){
  
digitalWrite(ledPin, HIGH);
  delay (500);
  digitalWrite(ledPin, LOW);
  delay (500);
  digitalWrite(ledPin, HIGH);
  delay (500);
  digitalWrite(ledPin, LOW);
}
// LED command for start of script
void ledstart(){
  
  digitalWrite(ledPin, HIGH);
  delay (1000);
  digitalWrite(ledPin, LOW);
  }
  // delay 100ms
void d(){
  delay(100);
}

OS X Code

http://drp.ly/Vci76

// Automatic twitter poster for OS X, User must be logged into twitter for this to work.
// Created by Seshan 30/04/10 1:34 AM

int ledPin = 11;


void setup() {
  
  pinMode(ledPin, OUTPUT); // put this before other led commands or the LED will be dim
  
  ledstart();     // lights up when connected
  delay(3000);   // delay for computer
  ledstart();  // lights up when payload starts
  // quits the pop up you get on OS X with new keyboards
  Keyboard.set_modifier(MODIFIERKEY_GUI);
  Keyboard.send_now();
  Keyboard.set_key1(KEY_Q);
  Keyboard.send_now();
  enter();  // hits enter, see below for commands
  d(); // this is a 100ms delay, see below for commands.
  spotlight(); // opens spotlight, see below for commands
  Keyboard.print("Terminal.app"); // types terminal
  enter(); 
  delay(1000);
  Keyboard.print("open http://www.twitter.com && killall Terminal"); // thanks to Psychosis for the killall terminal command
  d();
  enter();
  delay(4500);
  Keyboard.print("This is a test"); // this is what gets posted to twitter, change this to what ever you want
  d();
  Keyboard.set_key2(KEY_TAB);
  Keyboard.send_now();
  enter();
  Keyboard.set_key2(0);
  ledend();
  
  // delay to stop it running again, 9 sec.
  delay(9000);
}
  
  
void loop() {

}
// hits enter
void enter(){
  
  Keyboard.set_key1(KEY_ENTER);
  Keyboard.send_now();
  Keyboard.set_key1(0);
  Keyboard.send_now();
  
}
// opens spotlight
void spotlight(){
  
  Keyboard.set_modifier(MODIFIERKEY_GUI);
  Keyboard.send_now();
  Keyboard.set_key1(KEY_SPACE);
  Keyboard.send_now();
}
// LED command for end of script.
void ledend(){
  
digitalWrite(ledPin, HIGH);
  delay (500);
  digitalWrite(ledPin, LOW);
  delay (500);
  digitalWrite(ledPin, HIGH);
  delay (500);
  digitalWrite(ledPin, LOW);
}
// LED command for start of script
void ledstart(){
  
  digitalWrite(ledPin, HIGH);
  delay (1000);
  digitalWrite(ledPin, LOW);
  }
  // delay 100ms
void d(){
  delay(100);
}

Edited by Seshan
Link to comment
Share on other sites

why are you using d(); when theres already delay();.. seems like a waste of code?

you should send gui + r keys at the same time, speeds things up and user doesn't get a chance to click elsewhere

the majority of this code is just playing with the LED. could make it smaller/cleaner, but other than that

not bad.. it works, and serves a purpose

Edited by NanoyMaster
Link to comment
Share on other sites

Well, Assuming you are at the persons computer, it would be hard for them to click somewhere. I like having the LED's giving you feed back, so if something goes wrong, you know where it should of been in the script by the LED's blinking. I'm using d(); because I didn't feel like put delay(100); all the time, this way it saves some space, and having little delays helps prevent it from messing up.

*edit*, I also just realized i forgot to change it to terminal.app, since I don't use spotlight I use quicksilver, I have it set for just terminal. Another problem to think of. :|

Edited by Seshan
Link to comment
Share on other sites

  • 3 weeks later...

Hey great stuff!

I modified the [OSX] code to login to twitter and cut down on the un-necessary light blinking (cause i felt like it)

tell me what you think!

Please comment if I made a mistake im new to the Teensy and want to learn from my mistakes.

[OSX] Twitter poster

EDIT: whenever I add my code to the Codebox other text is being added
 so im going to upload in as picture

P.S this is Your code Edited by myself.

I take no credit for the original code and don't want you to take credit for the mistakes I might have made

EDIT:

Anyone? I need some feedback plz!

thanks.

.

post-18838-1274194997_thumb.png

Edited by Bobbers
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.

  • Recently Browsing   0 members

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