element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Arduino Forum Self-Destructing arduino code
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Suggested Answer
  • Replies 29 replies
  • Answers 1 answer
  • Subscribers 396 subscribers
  • Views 3183 views
  • Users 0 members are here
  • self.destructing.arduino.code
Related

Self-Destructing arduino code

dirtdiver
dirtdiver over 12 years ago

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)

  • Sign in to reply
  • Cancel

Top Replies

  • Former Member
    Former Member over 12 years ago in reply to dirtdiver +2
    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…
  • sonuame
    sonuame over 12 years ago in reply to Former Member +2
    @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…
  • ntewinkel
    ntewinkel over 12 years ago in reply to sonuame +2
    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…
  • ntewinkel
    0 ntewinkel over 12 years ago in reply to sonuame

    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.

    }

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • sonuame
    0 sonuame over 12 years ago in reply to ntewinkel

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

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • ntewinkel
    0 ntewinkel over 12 years ago in reply to sonuame

    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.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • mcb1
    0 mcb1 over 12 years ago in reply to ntewinkel

    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

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 11 years ago in reply to mcb1

    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.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 11 years ago

    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

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Robert Peter Oakes
    0 Robert Peter Oakes over 11 years ago

    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  ?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 9 years ago in reply to sonuame
    .
    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 9 years ago in reply to Robert Peter Oakes
    .
    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
<
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube