29 Replies Latest reply on Mar 23, 2016 10:48 AM by monaelwy

    Self-Destructing arduino code

    dirtdiver

      Hi everyone,

         so I've been wondering if there is a way to make a hidden button on a device (device wokring with ardunino) that will (once pressed) render the code useless - for example to delete values (val1, val2 ...) or in any way destroy the program that runs that device.

      Any ideas?

      Thanks,

      Lubo (Bo)

        • Re: Self-Destructing arduino code
          sonuame

          Try connecting one I2C EEPROM 24C256, and write the Encrypted string or Code via arduino board. Lets say 1710 is the code you have written in it.

          Now, Atmega328 microcontroler has one onboard EEPROM, Write a code 1710 in it too...

           

          Now in the Setup Section of your code, Compare any I2C device attached to the uC. and make a female socket for the connection of external EEPROM.

           

          Run your whole program of arduino if and only if the internal EEPROM contains 1710 and dont execute if this code is not saved. Once yopu plug in the EXTERNAL EEPROM, define a logic like, if the code of External and Internal EEPROM matches..it will erase the internal EEPROM completly and hence your entire Arduino

          sketch will be useless. Doesnt matter even if you reset it or Power off...

           

          Hope this one helps...!!

            • Re: Self-Destructing arduino code
              000Plasma000

              Here's an idea:

               

              when the button is pressed, you could just write all the values to 0 (or anything else, if you're trying to confuse the user by giving bogus readings), and put the chip in a never ending loop by using something like this:

               

              while(1)

              {

                   //do nothing here, or maybe keep clearing the values if you want

              }

               

              However, the code would start working again when you reset it, or of you power it off and then on again.

               

              What is this mysterious feature for anyway?

               

              One option I can think of (easy way out, no code) is to use a simple SPDT switch to connect the reset pin to ground (that way the micro can't do anything until you open the switch again), but this might not be suited to your (let's be honest, slightly dubious ) purposes. If the switch is hidden well enough, then whoever it's hidden from might not have a clue as to what's going on, unless they're familiar with microcontrollers and have really sharp eyes.

               

              Using the EEPROM to store variables seems a little overkill to me, unless for some reason you want them to be kept after you turn off the chip.

               

              If you want a way to permanently destroy all the code on the chip until it's reprogrammed, it get's a little more complex...

              If you're competent in programming in assembly, maybe you could somehow load the code into the RAM and go from there. This way, the code will vanish once the chip is powered off or reset. This seems like a daunting task to me, and forget using the Arduino environment to do this!

               

              Or you could just set fire to the thing, whatever works best

                • Re: Self-Destructing arduino code
                  dirtdiver

                    interesting ideas . Anyway i need it becouse im making a racing simulator (http://www.youtube.com/watch?v=y9m--orp8O8)  and the  idea is to put it in a gaming club (i've talked to the owner and its all good), now i know the guy , but its never bad to have a "dead man's switch" in case he decides to pull any stunts i can just "render the sim uselses" and gain leverage (im also putting a non-resetable timer in it to keep track at the time it was working)

                  In other words im just trying to cover all the angles here

                  it uses a teensy 3.0 (arduino doesnt have a joystick function) but its programed in the arduino IDE

                  i like the idea with the reset pit or a switch keeping the values at 0...i will keep thinking and see whats the best option (maybe all of them)

                  I was wondering if there is a way to irreversibly change a value to 0 or something similar so that once pressed the button ruins the code and it has to be reuploaded to the teensy

                    • Re: Self-Destructing arduino code
                      sonuame

                      Dude,, as per the video attached, I am pretty sure you're gonna mess with lots of Digital circuits and components..then why not a cheap eeprom.

                      I am not agreed with the method stated by Mr Rahul. Its not 100% control over your sketch. Protection means real digital protection. Not with any analog means...

                       

                      4 digit security lock can be easily made just with one keypad and without any microcontroller in it, just by Analog means but its not secure and thats why we use Microcontrollers

                      to provide it better security by digital Logics.

                       

                      Yeah Sure Reset Pin can workout for you but its really not practical.

                       

                      Make your whole sketch dependant on the values saved on onboard eeprom. And then dedicate a Key somewhere hidden if you want to or you can attach a small keypad if you want, to

                      destroy it with some specific code.

                       

                      When you'll enter exact Code by keypad or you pressed that dead man switch, It should erase the eeprom completly which will make your sketch null and void and won't work until unless you reupload it again.

                       

                      As per my experience,, This is the Best (I wont say easy)  protection to yor sim...

                      and it will be always there even if the power is out

                • Re: Self-Destructing arduino code
                  Cabe Atwell

                  This is an interesting idea and project. Keep it going and keep us all posted.

                   

                  C

                  • Re: Self-Destructing arduino code
                    000Plasma000

                    Yeah, you have 1K of internal EEPROM to mess around with, and it's dead easy to control with Arduino. You can do what Nico suggested and make the thing check for the important variable first before executing the never ending loop. Something like this (pseudocode, ceebs to write the real thing):

                     

                    //burn this program to the Arduino first

                     

                    void setup()

                    {

                         //write, say, the number 123 to eeprom adress 7 (completely arbitrary numbers I chose)

                    }

                     

                    void loop()

                    {

                         //nothing to do here

                    }

                     

                    //then erase that old program and write this new one

                     

                    void setup()

                    {

                         //whatever your normal code would require in the setup goes here

                    }

                     

                    void loop()

                    {

                         while(eeprom adress 7 == 123)

                         {

                              //work properly

                     

                              if(secret button pressed)

                              {

                                   //clear EEPROM address 7

                              }

                     

                         }

                            lcd.print ("don't mess with a programmer");

                    }

                     

                    I just thought of this code off the top of my head, I'm sure you can make it more efficient, maybe by using interrupts or something. No need for a keypad system or anything, unless you really want some password feature built into it. To reprogram the chip just pull it out of the DIP socket and stick it in your Arduino board, or include an ISP header in your design.

                     

                    Really cool project btw, hope it all goes well

                      • Re: Self-Destructing arduino code
                        ntewinkel

                        From what I understand, eeprom gets cleared when you upload a new sketch (you might want to test that just to make sure, of course).

                         

                        Also, from the docs for Read, it mentions that the value will be 255 if that location hasn't been written.

                         

                        So you'd simply have to do something like this:

                         

                        void setup() {

                        }

                         

                        void loop() {

                         

                             while (EEPROM.read(0) == 42) {  // you can use your own favourite number as the flag, of course.

                                  // self destruct button has been pressed

                                  // maybe blink a light indicating "malfuntion" ?

                             }

                         

                             // do regular work

                         

                             if (selfDestructButtonWasPressed()) {

                                  EEPROM.write(0, 42);

                             }

                         

                        }

                         

                        Cheers,

                        -Nico

                          • Re: Self-Destructing arduino code
                            mcb1

                            Nico

                            The EEPROM doesn't get overwritten with a new sketch.

                            You need to clear it. there is an example under the EEPROM library.

                             

                            There are are limited number of writes, but unlimited reads.

                             

                            I've been using it to store the date when the Go button is pressed. Each reboot checks to see if the new date is greater then the EEPROM, and acts accordingly.

                             

                            dirtdiver

                            A word of caution.

                            I would check to see if 'time bombs' and the like are legal.

                            It might pay to ensure the client is aware of these and accepts them. (in writing)

                             

                             

                            Mark

                              • Re: Self-Destructing arduino code
                                ntewinkel

                                Thanks Mark, that's good to know. I had done a quick search and I must've gotten something outdated or just wrong

                                So that would mean dirtdiver would just need a separate sketch to clear the one memory address he is using as the flag.

                                 

                                Interesting point about the legal side of it. I once put a time limit on a custom app, requiring a typed-in key to unlock it, and I'm pretty sure I would not have gotten paid without it!

                                 

                                dirtdiver, In terms of the number of writes available, you would only write the one memory location once per self-destruct button press. Or if the trigger is time related I suppose you could check it before writing so you don't re-write it unnecessarily.

                                  • Re: Self-Destructing arduino code
                                    dirtdiver

                                    yes in terms of number of writes available i will be OK, and as far as the legal side goes im not selling this im getting involved in a partnership, and the club is not mine so whats stopping the guy from saing thats his, i have no way of proving that i made the simulator and like i said i can gain leverage when i simply render the teensy useles. (I am also thinking about patenting the simulator but im not sure how to do that or what will the cost or time be like)(The other possibility is a contract which i will look into)

                                     

                                    Anyway thanks for the help,i will keep you posted on my progress!

                                      • Re: Self-Destructing arduino code
                                        000Plasma000

                                        Don't patent it!

                                         

                                        I tell you, it's a waste of time, money and effort. You need to pay thousands of dollars, and here's the worst part: you have to publish a detailed description of your product and how it works! You're just making it a hundred times easier for some el-cheapo manufacturer to copy it! They won't care if you have a patent. If you do decide to sue someone over copying it, then that's going to set you back quite a bit for a lawyer! There's no way, even if you win, that you'll get that much money back from the patent.

                                         

                                        If you decide to sell it (perhaps on a large scale) then there are precautions you can take to stop people from copying it. For example, you could get a custom PCB built for it, and sandpaper off all the markings on the ICs. If and when you decide to go big, then maybe a patent might be feasable. Also, if you don't really care about the money, and just want to get recognised, a patent might be a good idea, even now. Just know that you'll be paying a LOT of money for it. Think of how many goodies you can get on this website for $5000!

                                         

                                        ---

                                         

                                        Also, @Sunil, the EEPROM method may not necessarily be the best way. In fact, there may not be a 'best' way at all. It's one way of doing things, and it seems feasable. It all depends on what the kill switch is for, how much effort you are willing to go to write the code, how good you are at coding, your time constraints, etc, etc, etc. This kill switch idea is good, but I can see it causing some disputes. A dedicated self destruct button will tick off the club owner much more than a simple discreet reset switch (which by the way, is not analogue as you mentioned before - analogue refers to a range of voltages in this case, the reset switch still uses digital logic), and you can still use the switch for leverage. Just tell the guy you need to take it for 'servicing' and secretly flip the switch while pretending to calibrate stuff, and give him a long technincal explanation as to why it went bust, like "the internal temperature of the dual H-bridge stepper driver rose too far beyond the nominal". He won't know you designed it for leverage (which I'm sure will make him mad and ruin the partnership), but he will know that only you can fix it, which gives you the leverage. Also it requires no extra coding. In addition to this, constantly checking the EEPROM might be quite taxing to the microcontroller, especially since it's doing a LOT of other work - this simulator is pretty complex! You might find that it decreases performance. This might be in the form of jittery servos for example - even with simple programs, if the MCU is checking constantly for, say, a timer value, then the servo just freaks out and goes all over the place! You could optimise this out using interrupts and all that but that just adds to the complexity of your program!

                                         

                                        Again, this is also just one way of doing things. It may or may not be better than the EEPROM method, but it's up to dirtdriver to decide

                                          • Re: Self-Destructing arduino code
                                            sonuame

                                            @Rahul,,

                                            yeah i am agreed to you , I just told that Reset pin is too much a easy way to stop execution of the microcontroller for that complex machine.

                                             

                                            sure continously reading the EEPROM values sometimes may delay in response and surely it will impact the servo one day theoretically...but so far now I have not seen such a case yet..May be i have to do some more EEPROM stress analysis.

                                             

                                            What if we mount a small RTC IC (DS1307) and read the EEPROM values after a specefic period of time say once in 2 days or 4 days etc...coz that will surely give the chip some time to relax. And if the value is not there after 2 days...Simulater will shutoff...!! until unless the value is not saved in it again.

                                             

                                            DS1307 can last upto 5yrs approx with a single coin cell and we can detect from the Arduino or any other Microcontroller wether RTC is running or not, just incase if somebody plugs out the cell from it and make our program much stable and secured with it...

                                              • Re: Self-Destructing arduino code
                                                dirtdiver

                                                Yeah, thats what i heard about the patenting too, so its out of the game,

                                                also im not worried about reverse engineering couse all they are going to see is the teensy the code in it cant be extracted as far as I know (it can but it will be all messed up and not full- it will be pretty useles)

                                                I have a friend lawyer, i will talkmto him about a shor contract declaring that i have rights over the simulator or something similar i dont know yet .

                                                Im not a good programer,as you can see from the simulator i dont have that kind of money to fool around with , i dont have much time,I will try the EEPROM (at least for the educational purpose of it , but if it slows down the program, then i wont use it)

                                                • Re: Self-Destructing arduino code
                                                  ntewinkel

                                                  I really like Sunil's idea of it only checking after a few days! Much less obvious that way. You might also make it use a jumper on pins instead of a button, to prevent accidental presses.

                                                   

                                                  You could probably just use millis() to check, as it rolls over after 50 days, which gives plenty of time: http://arduino.cc/en/Reference/millis

                                                  So you could check at startup, and every time millis() is divisible by, say, 200,000 (2.3 days).

                                                   

                                                  Kind of like this:

                                                   

                                                  void setup() {

                                                         if (EEPROM.read(0) == 42) {

                                                              selfDestructLoop();

                                                         }

                                                  }

                                                   

                                                  void loop() {

                                                   

                                                       if (millis() % 200000ul == 0) {  // test with a smaller number. I think you need the "ul" to indicate "unsigned long" to allow for the big number.

                                                            if (EEPROM.read(0) == 42) {

                                                                 selfDestructLoop();

                                                            }

                                                       }

                                                   

                                                       // do regular work

                                                   

                                                       if (selfDestructButtonWasPressed()) {

                                                            EEPROM.write(0, 42);

                                                       }

                                                   

                                                  }

                                                   

                                                  void selfDestructLoop() {

                                                       // blink the warning light.

                                                  }

                                                    • Re: Self-Destructing arduino code
                                                      sonuame

                                                      @Nico,,

                                                      I guess, millis() gets reset once the sim is shutdown, hw exactly we can track the number of days passed

                                                       

                                                      For me RTC was the good choice for the timing purpose..its small, cheap and very much reliable

                                                      I hve made a number of RTCs at home.

                                                       

                                                      @dirtdriver

                                                      So you started the work dude....!!!

                                                        • Re: Self-Destructing arduino code
                                                          ntewinkel

                                                          Hi Sunil,

                                                           

                                                          I agree, millis() gets reset on startup. My thought was that if the sim is running and the button was pressed, it would run for a few days and then shut down. If it is restarted anytime sooner after the button was pressed, it would fail immediately and it would look like there was a startup failure of some sort.

                                                           

                                                          I do like your RTC idea too - they're not too pricey either.

                                                            • Re: Self-Destructing arduino code
                                                              mcb1

                                                              If I might be bold enough to suggest the following :-

                                                               

                                                              Have a number in the EEPROM.

                                                              Also have the number of starts in EEPROM.

                                                              Read both at Power-up/Arduino reset, and add one to starts, re-writing it back to EEPROM.

                                                              You get more than 10k writes, which is 27 years at once a day. (minimum)

                                                               

                                                              If the button is pressed, clear the number OR replace it with the number of starts.

                                                              At next power-up when you read it, either it goes into 'fail' mode, or does x more starts before going into 'fail' mode.

                                                               

                                                              No need for extra hardware.

                                                               

                                                               

                                                              Mark

                                                                • Re: Self-Destructing arduino code
                                                                  pyrotuc

                                                                  ok, i know i am resurrecting this thread from the dead, i just found it too interesting not to contributed. and disclaimer, it is admittedly very scatterbrained and i was editing on the fly and did not organize *all* of my thoughts well. re-reading it i can tell there is a lot of jumbled thoughts, kinda douglass adams style, but i swear english is my first language. much apologies, very embarrassed, so ADD

                                                                   

                                                                  ive thought about this very thing quite a bit. i work with a lot of people that dont pay me to ask questions

                                                                   

                                                                  first, you need to consider the situation. will you be able to physically access the machine to de-activate it? if so, there are a number of ways to trigger this. second, decide on what level of destruction you want. should it present itself as an error, mimic just crapping out? make it clear you are not to be effed with? simple reversible in-code deactivation? erasing values in memory or elsewhere? silent destruction of the mcu? overt destruction?

                                                                   

                                                                  as for triggering, you could add a female headphones jack, and connect it to pins. get a male, and attach a resistor (possibly variable, rotated by the plug housing), or a capacitor. something like that with a known, easily measurable characteristic. so that a read on the pins can trigger the destruction method. the teensy 3 also has (capacitive?) touch support on a number of pins. these could be attached to screws or the like on the housing of the device, such that when pins are touched in the way you define, it triggers whatever. time delay dead-man switch should be easy on the teensy 3, it just need a crystal and has an RTC already on board. 433/315mhz transmitter/receivers are pretty cheap these days. 4 button remote with a nice receiver board that has 4 pins that go high corresponding to the buttons, momentary such taht you  ould use it like a wireless 4 button keypad, is $4 on ebay. you can attach an IR decoder to the teensy to trigger that way, if the device is in view of a window, for your remote, you can use a ordinary *red* laser pointer in lieu of the IR LED. you can use a microphone to pick up a pulse train and decode, maybe even go all the way to DTMF. use your cellphone up real loud on speakerphone to generate the DTMF tones.along that line, the ultrasonic rangefinders are incredibly cheap, and the normal distance-measuring code would not need much modification to just listen for a pulse train. you can use magnetic reed switches, position on the inside of the housing, such that if you put 1 or more magnets in the corresponding location, it triggers the destruct. taking the same concept further, RFID tags could be utilized. if you want to go all out, there are GSM kits for $60 to give you some seriously *remote* control, you could always use a burner phone with a headset jack, where the audio out wired to a pin, triggering when the phone gets a call, mad-man bomber style.  there are chemical avenues, corroding a contact intentionally, evolution of heat, precipitation of electrolytes in water such that its measured resistance would be different. a vial with powders, that just need water or other liquid added to it start the reaction. or thermal, attach a thermometer somewhere on the housing where you could hit it with a butane lighter, when the temp measures above something that would never happen with normal use. you can use physical pull sticks, askin to the plastic tab you have to pull out of the battery housing for toys. a stripped screw in a stripped socket works. a metal pin can be used to close the gap between two springy brushes. you can use an optical interrupter, to detect the removal or insertion of something into the gap it uses. if you really want to be slick, you can set up a modified screw in a modified socket to act something like a low-key keyswitch, closing the gap of metal contacts, or using the mechanical rotation to activate other rube goldberg like methods (releases a bb that travels down a tube to connect contacts in the bottom, or when it rotates it rotates a flap that interrupts or releases something, makes a magnifying glass burn a string that releases a bird that pecks on a switch and something with a hamster wheel). there are glass-breakage sensors for large glass fronts, i believe it detects the high pitch crack sound, probaby would work mounted to metal housing when you hit it with a hammer.

                                                                  you can of course use a timer, setup to put random sway  on the length of time, where you tell the guy you it just needs to be reset periodically. 

                                                                   

                                                                  a pretty good dead-man style method, could be a timer where it shuts down if you have not reset the timer, by using the capacitive(i think?) touch sens pins on the teensy, connecting to screws or other innocuous things on the surface of the house, so that every x days, you have to go and touch specific points to reset the counter. i doubt anyone would catch on, unless the frequency of needing resets catches attention.

                                                                   

                                                                  and of course, these methods can be combined.

                                                                   

                                                                  now the fun part, destruction. roughly in order of less noticeable to very extreme

                                                                   

                                                                  as mentioned before, code can interact with eeproms. sometimes you can still find the old school ones with the glass window than can be used to erase them with UV light. UV diodes are cheap these days, and those old proms are surely cheap. why kill it slowly with writes when you can flash it at once, more efficiently and surely more consistent results. if you can get another teensy, one can be used to reprogram/deprogram the other, when i got the arduino nano (or is it micro?), one of the example sketches is it acting like a keyboard, typing out a new program in the compiler and uploading to itself. obviously that method relies on having a computer with the compiler installed and running, but as a proof of concept, i imagine its promising. nichrome wire can be very handy for something like this, how is easily conducts with low current, and destroys itself somewhat cleanly, as long as there is nothing near it it can ignite. since its driven by resistive heating, the moment it gets hot enough to melt and lose contact, it stops heating up, so the amount of heat produced can be easily limited by selecting the right diameter.  you can use nichrome wire as the wire for the power supply, with appropriate thickness that with normal use, it does not heat up and melt, but if you make the teensy draw more power like connecting to ground through a resistor, or really anything that causes it to draw more power, it would act like a fuse and disconnect the power supply. encapsulating the nichrome with thin heat-shrink tubing, it will look like any other insulated wire. you can set up a somewhat overly simplistic set of latches using dpdt relays, where it keeps conducting with no power to the coils, but then if you pulse the right coil, it un-latches until manually reset. relays could also be used to connect/disconnect the data pins of USB. you could even get one of the newer tip-ring-ring-shield headphone jack/pug to convey the USB to the plug and then a modified USB cable terminated with TRRS plug.  X10 receiver switches for appliances generally use a switch that will maintain its state with no power, they often employ interesting techniques of a small motor rotating a pin, or something interacting with a very primitive solenoid to move a contact bar across terminals, they are often clever and neat. if you include a battery supply to the teensy, you can generate a pattern from switching the main supply on and off to enable/disable, just have an addition wall plug inside the machine that puts out 3vdc, connected to a pin that looks for the correct pulse sequence.

                                                                   

                                                                  for a quasi-permanent destruct (as in, probably destroys itself, but possibly recoverable by a smart person), magnetics are an attractive option. wrapping some enameled wire around various components can surely put them out of commission. attacking the unprotected surface of the board, you can cause various shorts by applying something conductive. some nichrome wire twisted together with some solder and plenty flux, will definitely render the board inoperable. use a thickness of nichrome that it acts more as a heating element, melting the solder to splash on the board. if you play it just right, get the nichrome to melt the solder first, where it burns itself out after the solder is gone.

                                                                   

                                                                  now we get to where the level of obviousness and destruction matters. the above methods would be good if you need to have it look like it did not intentionally self destruct. however, if your "shady" situation allows for creative and overt methods of self-desctuct, you can have a wwwwhhhoollleee lot of fffffuuunnn.

                                                                   

                                                                  probably the easiest would be to short itself out, likely destroying the uc. theres a bunch a ways to do that, i assume we dont need to regurgitate them here. the most fun would be a pyrotechnic method. as stated earlier, nichrome wire can be very handy in this situation. it can act like a very simple fuse as described above, or it can be used as an initiator for a somewhat more beautiful death. model rocket igniters are very handy if you prefer it over nichrome. if you want to simulate a legit idiopathic shorting out, adding a firecracker to the above solder/nichrome would sure make it sound like it shorted the eff out something good, i recommend lady fingers.you could put a layer of saran wrap over the board, and put a burning yet not explosive powder pyrotechnic mix that more just smolders to ensure a complete destuction. of course, you could just use gunpowder, but dried herb (not THAT king, something more like sage smudge sticks) would be less alarming, as it will just sit there smoldering, surely entertaining anyone nearby with the smoke it puts out.  if you want to totally nerd out, its pretty simple to create a small pinch that would produce an electromagnet pulse (EMP). you just get a thin tube (wrap a piece of paper over a tube that is around 3mm in diameter, get a form something like a 3mm tube. apply a thin layer of glue, and then wrap some 28-30 gauge enameled wire (it can be found it craft sections as well as electronics stores) carefully down the longest you can have the tube go before space is an issue, apply another thin layer of glue let it dry and take it off the form, then fill the inside of the tube with black powder or flash powder. the idea is that you get the coil to be producing the strongest magnetic field it can, and then ignite one end of the tube, as the reaction travels up the tube, it destroys the coil going up the tube, compressing (pinching) the coil, concentrating the EM energy, resulting in a strong EM pulse. ive never done that but it sure sounds cool. itd be a tiny one so the effects would be extremely localized, especially inside a metal housing, so its unlikely anything else would be affected. you could release various caustic and corrosive chemicals onto the board. a few loops of nichrome wire around a small section of a plastic straw holding your chemical of choice. wrap saran wrap over the board a layer or two, put a layer of potassium permanganate and then your straw, filled with glycerine, and then another layer of saran to keep it in place. the kmn04 oxidizes the glycerine in a pretty energetic exothermic reaction that actually gets hot enough it can ignite thermite, and many consider it the prefered method of starting thermote. obviously, if you add powdered iron oxide and aluminum that at least is very small pieces  chopped up, you can get an amazingly hot reaction. if you use magnalium(50/50 al:mg) instead of aluminum, the reaction is much more energetic. it WILL melt a hole through whatever its on, melting a hole down to the ground, china syndrome like. you really, really should probably not do that. but if you do, you will send a damn clear message.

                                                                   

                                                                  for more realistic methods, use a timer with a generous amount of random controlling the range of time it needs to be reset, using touch sense, twisting a screw, tapping an otherwise normal input button a specific number of times, just like getting cheat codes in mario. "storing" the intended  state inside a relay, system memory, nichrome wire fuse, capacitor, external eep, as detailed towards the top of this thread (i gotta say, thats pretty slick). id definitely do the tip-ring-ring-shield headphone jack to connect to USB should you ever need to repgram the device with out the exploratory surgery. id also run it through a few relays so that the jack could be electrically controlled to connect or disconnect the data pins. if you want to take it to the next lever, get magnetic reed switches, very easy to place them at various random place on the inside of the housing surface, not visible from the outsde. just stick a few magnets in the right place and BAM it either disables  or enables your lockout/restore method, and also makes you look very mysterious.

                                                                   

                                                                  so yeah, not to just regurgitate the anarchistic cookbook, but you have a whole lot of choices.

                                            • Re: Self-Destructing arduino code
                                              000Plasma000

                                              Yeah the EEPROM doesn't change unless you specifically write something else to it. It also stays even when you turn off the power.

                                               

                                              The EEPROM on the atmega328p (and most AVRs) is good for around about 100 000 writes. That's probably not going to be a problem for you. The main flash memory of the chip, incidentally, is only good for approximately 10 000 writes. One of my next projects is going to be an "EEPROM destroyer", to see how many cycles I can get out of this thing! Some videos I've seen have gotten about 120 000 writes!

                                                • Re: Self-Destructing arduino code
                                                  dirtdiver

                                                  Thanks for all the replies,the EEPROM looks like the thing i need, i will get into it and keep you posted!

                                                  Oh one mroe thing im wokring with a teensy 3.0 with a

                                                  MK20DX128

                                                  32 bit ARM

                                                  Cortex-M4

                                                  48 MHz

                                                   

                                                  and the EEPROM is 2048, i dont know how many writes i have, but it shouldn't be a problem, right?

                                                  • Re: Self-Destructing arduino code
                                                    mcb1

                                                    Rahul

                                                    Someone in the Arduino.cc forums did a self destruct, by writing and then reading the address.

                                                     

                                                    The 10/100k write is the MINIMUM the manufacturer guarantees it will work for.

                                                     

                                                    I think (hazy memory) it was more like 1m write cycles he got.

                                                     

                                                     

                                                    Anyway as everyone has posted, it only needs to be written once.

                                                     

                                                    dirtdiver

                                                    You can run the button check routine as an interrupt, or whenever you read other inputs.

                                                    This would clear the EEPROM (or write to it) and on next powerup, when it checks.......

                                                     

                                                    To make it look genuine, after the 'self destruct', you could always make it do a loop that looked like it 'booted' up then died and repeated.

                                                     

                                                    "Genuine failure mate, probably something inside the micro .....I can fix it, but btw about that account..."

                                                     

                                                    I have been known to remove the chip identity by sanding it off, when we didn't want it reverse engineered.

                                                    Black spray paint, or encasement in rubber solution or epoxy (with glass) is also frustrating.

                                                     

                                                    Mark

                                                    1 of 1 people found this helpful
                                                  • Re: Self-Destructing arduino code
                                                    kulinti

                                                    you want to kill the chip? When secret button is pressed, energize a relay with contacts tied to 5V and GND of the Arduino or maybe tie the other contact to the mains...that should fry everything

                                                    • Re: Self-Destructing arduino code
                                                      peteroakes

                                                      is the idea to preserve the use of the hardware and only destroy the currently uploaded code or do you want the boot loader, and even the controller rendered un-usable  ?