SHARE
TWEET

Untitled

Xyzzy Nov 10th, 2019 111 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <Keyboard.h>
  2.  
  3. /* Modify the following definitions to fit your wireless and enrollment credentials. */
  4.  
  5. #define device_version 75 // Change to the ChromeOS version you expect to use with Centipede; Changes have been reported in the following ranges 58-68, 69, 70
  6.  
  7. #define wifi_name "detnsw" // Define SSID for your wireless connection.
  8. #define wifi_pass "-----" // Define the password for your wireless connection.
  9. #define wifi_security 2 //[0,1,2] Set to 0 for open, 1 for WEP, 2 for WPA
  10. #define login "warrick.harding1" // First part of email address
  11. #define domain "education.nsw.gov.au" // Domain to enroll to
  12. #define username "warrick.harding1@education.nsw.gov.au" // Define the user name for enrolling the device.
  13. #define password "----" // The password for the enrollment GAFE account.
  14. #define pac_address "http://pac.det.nsw.edu.au/fib/proxy.pac" // Address to the PAC file if using a proxy server
  15.  
  16. // Use these options to deter mine if you want to disable analytics, skip asset ID, or if you need to slow down the Centipede
  17.  
  18. #define sendUsageToGoogle 0 //[0,1] Set to 0 if you want to un-check the box to send usage analytics to Google
  19. #define shutdown_when_finished 0 //[0,1] Set to 0 if you want Centipede to stop at the asset ID and location screen
  20. #define selected_on_boot 1 //[0,1,2,3]  Active location when device poweron : 3 - "Let's go", 2 - accessibility, 1 - language (Default), 0 - menu
  21.  
  22. /* These are advanced options. The defaults should be fine, but feel free to tweak values below. */
  23.  
  24. #define setWiFi true //[true,false] Set to false for devices that already have WiFi setup and have accepted Terms of Service (ToS)
  25.  
  26. // Use this area for advanced network setup options
  27. #define advancedNetworkSetup true //[true,false] Set to true for EAP configuration, and fill out the definitions below
  28. #define eapMethod "PEAP" // Valid options are "LEAP" "PEAP" "EAP-TLS" or "EAP-TTLS" - Note that they require the quotes to work properly
  29. #define phaseTwoAuthentication 3 //[0,1,2,3,4,5,6] Set to 0 for automatic, 1 for EAP-MD5, 2 for MSCHAP(v2 pre v69; v1 V69+, 3 for MSCHAPv2, 4 for PAP, 5 for CHAP, 6 for GTC; v69+)
  30. #define serverCaCertificateCheck 1 //[0,1] 0 is default, 1 is "Do not check"
  31. #define subjectMatch "" // Fill in subject match here if needed for advanced wireless
  32. #define identity "srv1326wifi@detnsw" // Fill in identity here if needed for advanced wireless
  33. #define anonymousIdentity "" // Fill in anonymous identity here for advanced wireless
  34. #define saveIdentityAndPassword 0 //[0,1] Set to 1 to save identity and password. NOT RECOMMENDED
  35. #define sso 1 //[0,1] Set to 1 if using Single Sign On - NOTE: May need additional configuration in Advanced Network Setup around line 182.
  36. #define proxy 1 //[0,1] Set to 1 if using PAC file proxy
  37.  
  38. // Use this section for additional non-traditional methods
  39. #define longer_enrollment_time 10 // Set to additional seconds to wait for Device Configuration and Enrollment
  40. #define update_via_guest 0 //[0,1] Set to 1 to go into Guest Mode and navigate to chrome://chrome and Check for Updates
  41. #define powerwash 0 //[0,1] Powerwash the device BEFORE enrollment is completed - NOTE: Will not work on ENROLLED devices. Used for Setting up Centipede.
  42. #define sign_in 0 //[0,1] Set to 1 to sign-in to the device after enrollment - NOTE: Will not sign-in if update_via_guest or powerwash is set to true;
  43. #define remove_enrollment_wifi 0 //[0,1] Set to 1 to remove the enrollment wifi network. *sign_in also must be true* - NOTE: Only set to true when Chrome Device Network has been pulled down
  44. #define enroll_device_cert 0 //[0,1] Set to 1 if enrolling device wide certificate *sign_in also must be true* - NOTE: Works best if user _*only*_ has Certificate Enrollment extension force installed
  45.  
  46. #define slowMode 0 // [0,1] Set to 1 if Centipede appears to be moving too quickly at any screen. This will slow down the entire process
  47. #define update_wait_time 90 // Set to seconds to wait for Update with update_via_guest before exiting guest mode.  Update will continue while device is online.
  48.  
  49. /* Do not modify anything below this line unless you're confident that you understand how to program Arduino or C */
  50.  
  51. // Version Definition
  52. #define VERSION_69 (device_version >= 69)
  53. #define VERSION_70 (device_version >= 70)
  54.  
  55. // Special characters definition
  56. #define KEY_LEFT_CTRL   0x80
  57. #define KEY_LEFT_SHIFT  0x81
  58. #define KEY_LEFT_ALT    0x82
  59. #define KEY_RIGHT_CTRL  0x84
  60. #define KEY_RIGHT_SHIFT 0x85
  61. #define KEY_RIGHT_ALT   0x86
  62. #define KEY_UP_ARROW    0xDA
  63. #define KEY_DOWN_ARROW  0xD9
  64. #define KEY_LEFT_ARROW  0xD8
  65. #define KEY_RIGHT_ARROW 0xD7
  66. #define KEY_BACKSPACE   0xB2
  67. #define KEY_TAB         0xB3
  68. #define KEY_ENTER       0xB0
  69. #define KEY_ESC         0xB1
  70. #define KEY_CAPS_LOCK   0xC1
  71.  
  72. int buttonPin = 2;  // Set a button to any pin
  73. int RXLED = 17;
  74. static uint8_t __clock_prescaler = (CLKPR & (_BV(CLKPS0) | _BV(CLKPS1) | _BV(CLKPS2) | _BV(CLKPS3)));
  75.  
  76. void setup()
  77. {
  78.   setPrescaler(); // Set prescaler to highest clock speed
  79.   Keyboard.begin(); // Start they keyboard emulator
  80.   pinMode(buttonPin, INPUT);  // Set up the debugging pin. If you want to debug the code, use a length of wire to connect pins 2 and GND on the board
  81.   digitalWrite(buttonPin, HIGH);
  82.  
  83.   pinMode(RXLED, OUTPUT); // Configure the on-board LED
  84.   digitalWrite(RXLED, LOW);
  85.   TXLED1;
  86.   if (digitalRead(buttonPin) == 0) {
  87.     showSuccess();
  88.   }
  89.   wait(5); // Wait for all services to finish loading
  90. }
  91.  
  92. void loop() { // Main Function - workflow is called within loop();
  93.   if (digitalRead(buttonPin) == 1 ) { // Check for debugging. If not debugging, run the program
  94.     showVersion();
  95.     if (!update_via_guest){ // Guestmode not available for devices tagged for enrollment
  96.       enterEnrollment();
  97.     }
  98.     if (setWiFi){
  99.       wifiConfig(); // Enter the wifi configuration method (written down below)
  100.       ToS(); // Accept Terms of Service
  101.     }  
  102.     TXLED1; // Toggle the TX on-board LED
  103.     wait(15 + longer_enrollment_time); // Wait device to download configuration
  104.     while (digitalRead(buttonPin) != 1) {
  105.       bootLoop();
  106.     }
  107.     TXLED0;
  108.     if (update_via_guest){
  109.       updateViaGuest(); // Enrollment keypress at the end (around line 447)to continue the enrollment process
  110.     }
  111.     enterCredentials(); // Max progress with powerwash set to true - Will Powerwash after typing the password but before submitting
  112.     wait(50 + longer_enrollment_time); // wait for Enrollment to complete
  113.    
  114.     if (sign_in && shutdown_when_finished){ // Do not sign-in if "shutdown_when_finished" is false
  115.       Keyboard.write(KEY_ENTER);
  116.       wait(10);
  117.       enterCredentials();
  118.       wait(90); // Wait for profile to load
  119.       if (enroll_device_cert){
  120.         certificateEnrollment(); // Enroll Device wide Certificate
  121.       }
  122.       if (remove_enrollment_wifi){
  123.        removeEnrollmentWifi(); // Remove non-managed Enrollment WiFi
  124.       }
  125.     }
  126.     if (shutdown_when_finished) {
  127.       shutDown();
  128.     }
  129.     showSuccess();
  130.   }
  131.   bootLoop();
  132. }
  133.  
  134. void bootLoop() {
  135.   //      digitalWrite(RXLED, LOW);   // set the LED on
  136.   TXLED0; //TX LED is not tied to a normally controlled pin
  137.   delay(200);              // wait for a second
  138.   TXLED1;
  139.   delay(200);
  140.   TXLED0; //TX LED is not tied to a normally controlled pin
  141.   delay(200);              // wait for a second
  142.   TXLED1;
  143.   delay(800);
  144. }
  145.  
  146. void showSuccess() {
  147.   digitalWrite(RXLED, HIGH);  // set the LED off
  148.   while (true) {
  149.     bootLoop();
  150.   }
  151. }
  152.  
  153. void repeatKey(byte key, int num) {
  154.   for (int i = 0; i < num; i++) {
  155.     Keyboard.write(key);
  156.     wait(1);
  157.   }
  158. }
  159.  
  160. void blink() {
  161.   digitalWrite(RXLED, LOW);
  162.   //  TXLED1;
  163.   delay(250);
  164.   digitalWrite(RXLED, HIGH);
  165.   //  TXLED0;
  166.   delay(250);
  167. }
  168.  
  169. void wait(int cycles) {
  170.   for (int i = 0; i < cycles; i++) {
  171.     blink();
  172.     if (slowMode) {
  173.       delay(250);
  174.     }
  175.   }
  176. }
  177.  
  178. void enterCredentials() {
  179.   wait(5);
  180.   Keyboard.print(username);
  181.   wait(3);
  182.   Keyboard.write(KEY_ENTER);
  183.   wait(8);
  184.   if (sso){
  185.    //Keyboard.write(KEY_TAB);
  186.  
  187.    Keyboard.print(login);
  188.    Keyboard.write(KEY_TAB);
  189.    wait(1);
  190.   }
  191.   Keyboard.print(password);
  192.   if (powerwash){
  193.     wait(5);
  194.     Powerwash();
  195.   }
  196.   wait(3);
  197.   Keyboard.write(KEY_ENTER);
  198.   wait(3);
  199. }
  200.  
  201. void enterEnrollment() {
  202.   Keyboard.press(KEY_LEFT_CTRL);
  203.   Keyboard.press(KEY_LEFT_ALT);
  204.   Keyboard.write('e');
  205.   Keyboard.release(KEY_LEFT_ALT);
  206.   Keyboard.release(KEY_LEFT_CTRL);
  207.   wait(1);
  208. }
  209.  
  210. void ToS(){
  211. // Terms of Service screen
  212.   wait(15);
  213.   repeatKey(KEY_TAB, 3);
  214.   if (!sendUsageToGoogle) {
  215.     Keyboard.write(KEY_ENTER);
  216.     wait(1);
  217.   }
  218.   repeatKey(KEY_TAB, 3);
  219.   wait(1);
  220.   Keyboard.write(KEY_ENTER);
  221. }
  222.  
  223. void wifiConfig() {
  224.   // Access the Network option from the system tray (Status Area).
  225.   Keyboard.press(KEY_LEFT_SHIFT);
  226.   Keyboard.press(KEY_LEFT_ALT);
  227.   Keyboard.write('s');
  228.   Keyboard.release(KEY_LEFT_ALT);
  229.   Keyboard.release(KEY_LEFT_SHIFT);
  230.   wait(2);
  231.   //to select the Network
  232.   repeatKey(KEY_TAB, 3 + VERSION_70);  // 3 for pre v70, 4 for ver 70 (black menu)
  233.   wait(1);
  234.   Keyboard.write(KEY_ENTER);
  235.   wait(1);
  236.   //to select the 'add Wifi' icon
  237.   repeatKey(KEY_TAB, 3);
  238.   Keyboard.write(KEY_ENTER);
  239.   wait(1);
  240.   // SSID
  241.   Keyboard.print(wifi_name);
  242.   wait(1);
  243.   // TAB
  244.   Keyboard.write(KEY_TAB);
  245.   wait(1);
  246.   if (wifi_security == 0) {
  247.     repeatKey(KEY_TAB, 2);
  248.   } else {
  249.       if (advancedNetworkSetup) {
  250.         setupAdvancedNetworkConfig();
  251.       }
  252.       else{
  253.         repeatKey(KEY_DOWN_ARROW, wifi_security); //[1]WEP, [2]PSK (WPA or RSN), [3]EAP;
  254.      
  255.     // TAB
  256.     Keyboard.write(KEY_TAB); //[1,2]password, [3]EAP method;
  257.     wait(1);
  258.     // type wifi password
  259.     Keyboard.print(wifi_pass);
  260.     repeatKey(KEY_TAB, 3);
  261.    }
  262.   }
  263.   wait(1);
  264.   // Enter
  265.   Keyboard.write(KEY_ENTER); // Connect
  266.   // Delay 15 seconds to connect
  267.   wait(15);
  268.   if (proxy) {
  269.       Keyboard.press(KEY_LEFT_SHIFT);
  270.       Keyboard.press(KEY_LEFT_ALT);
  271.       Keyboard.write('s');
  272.       Keyboard.release(KEY_LEFT_ALT);
  273.       Keyboard.release(KEY_LEFT_SHIFT);
  274.       wait(2);
  275.       repeatKey(KEY_TAB, 4);
  276.       Keyboard.write(KEY_ENTER);
  277.       repeatKey(KEY_TAB, 3);
  278.       Keyboard.write(KEY_ENTER);
  279.       wait(1);
  280.       repeatKey(KEY_TAB, 2);
  281.       Keyboard.write(KEY_DOWN_ARROW);
  282.       wait(1);
  283.       Keyboard.print(pac_address);
  284.       Keyboard.write(KEY_ENTER);
  285.       Keyboard.write(KEY_ESC);
  286.   }
  287.   repeatKey(KEY_TAB, 3);
  288.   wait(2);  
  289.   Keyboard.write(KEY_ENTER); // Click "Let's Go"
  290.   wait(1);
  291.   repeatKey(KEY_TAB, 2 + VERSION_70); // 3 for version 70+ (black menu)
  292.   // After connecting, enter the enrollment key command to skip checking for update at this point in the process
  293.   if (!update_via_guest){
  294.     enterEnrollment();
  295.   }
  296.   wait(1);
  297.   Keyboard.write(KEY_ENTER); // Click "Next"
  298. }
  299.  
  300. void shutDown() { // Shutdown if not signed in, Sign out if signed in
  301.   // Access the Network option from the system tray (Status Area).
  302.   Keyboard.press(KEY_LEFT_SHIFT);
  303.   Keyboard.press(KEY_LEFT_ALT);
  304.   Keyboard.write('s');
  305.   Keyboard.release(KEY_LEFT_ALT);
  306.   Keyboard.release(KEY_LEFT_SHIFT);
  307.   wait(2);
  308.   repeatKey(KEY_TAB, 1 + sign_in);
  309.   repeatKey(KEY_ENTER, 1);
  310. }
  311.  
  312. void setupAdvancedNetworkConfig() {
  313.   //Starting at Security box
  314.   if (VERSION_69 == 1){
  315.     repeatKey(KEY_DOWN_ARROW, 3); // Select Security "EAP" (v69);
  316.         Keyboard.write(KEY_TAB);
  317.   }else{
  318.     //ARROW_DOWN x3 WEP, PSK, EAP
  319.     repeatKey(KEY_TAB, 2);
  320.     Keyboard.write(KEY_ENTER);
  321.     wait(1);
  322.     //SSID (again);
  323.     Keyboard.print(wifi_name);
  324.     Keyboard.write(KEY_TAB);
  325.     //@EAP Method
  326.   }
  327.  
  328.   if (eapMethod == "LEAP") {
  329.     // Default is LEAP v69+
  330.     repeatKey(KEY_DOWN_ARROW, 1 - VERSION_69);
  331.     Keyboard.write(KEY_TAB);
  332.     // Identity
  333.     Keyboard.print(identity);
  334.     Keyboard.write(KEY_TAB);
  335.     wait(1);
  336.     Keyboard.print(wifi_pass);
  337.     repeatKey(KEY_TAB, 2);
  338.     wait(1);
  339.     Keyboard.write(KEY_ENTER); // Save Identity and Password (true);
  340.     repeatKey(KEY_TAB, 2);
  341.     Keyboard.write(KEY_ENTER); // Connect;
  342.   } else if (eapMethod == "PEAP") {
  343.     // Select PEAP method
  344.     repeatKey(KEY_DOWN_ARROW, 2 - VERSION_69);
  345.     Keyboard.write(KEY_TAB);
  346.     wait(1);
  347.     // EAP Phase 2 authentication
  348.     // If phase two authentication is defined, select it
  349.     if (phaseTwoAuthentication) {
  350.       repeatKey(KEY_DOWN_ARROW, phaseTwoAuthentication); // [0]Automatic, [1]EAP-MD5, [2]MSCHAP(v2 pre-v69;v1 v69+, [3]MSCHAPv2, [4]PAP, [5]CHAP, [6]GTC : v69)
  351.     }
  352.     Keyboard.write(KEY_TAB);
  353.     // Server CA Certificate
  354.     if (serverCaCertificateCheck) {
  355.       Keyboard.write(KEY_DOWN_ARROW);//change to "DO NOT CHECK"
  356.     }
  357.     Keyboard.write(KEY_TAB);
  358.  
  359.     // Identity
  360.     Keyboard.print(identity);
  361.     Keyboard.write(KEY_TAB);
  362.     wait(1);
  363.     Keyboard.print(wifi_pass);
  364.     repeatKey(KEY_TAB, 2);
  365.  
  366.     // Anonymous Identity
  367.     Keyboard.print(anonymousIdentity);
  368.     Keyboard.write(KEY_TAB);
  369.     Keyboard.write(KEY_ENTER); //Save ID and PW
  370.     repeatKey(KEY_TAB, 1 + VERSION_69); //End on Connect  /v69+
  371.   } else if (eapMethod ==  "EAP-TLS") {
  372.     // Select EAP-TLS method
  373.     repeatKey(KEY_DOWN_ARROW, 2);
  374.     Keyboard.write(KEY_TAB);
  375.     //EAP Phase 2 authentication
  376.     // If phase two authentication is defined, select it
  377.     if (phaseTwoAuthentication) {
  378.       repeatKey(KEY_DOWN_ARROW, phaseTwoAuthentication); // [0]Automatic, [1]EAP-MD5, [2]MSCHAP(v2 pre-v69;v1 v69+, [3]MSCHAPv2, [4]PAP, [5]CHAP, [6]GTC : v69)
  379.     }
  380.     Keyboard.write(KEY_TAB);
  381.     // Server CA Certificate
  382.     if (serverCaCertificateCheck) {
  383.       Keyboard.write(KEY_DOWN_ARROW); // Change to "DO NOT CHECK"
  384.     }
  385.     Keyboard.write(KEY_TAB);
  386.  
  387.     // Subject match
  388.     Keyboard.print(subjectMatch);
  389.     Keyboard.write(KEY_TAB);
  390.  
  391.     // Identity
  392.     Keyboard.print(identity);
  393.     repeatKey(KEY_TAB, 3);
  394.  
  395.   } else if (eapMethod == "EAP-TTLS") {
  396.     repeatKey(KEY_DOWN_ARROW, 4);
  397.     Keyboard.write(KEY_TAB);
  398.  
  399.     // If phase two authentication is defined, select it
  400.     if (phaseTwoAuthentication) {
  401.       repeatKey(KEY_DOWN_ARROW, phaseTwoAuthentication);
  402.     }
  403.     Keyboard.write(KEY_TAB);
  404.  
  405.     // Server CA Certificate
  406.     if (serverCaCertificateCheck) {
  407.       Keyboard.write(KEY_DOWN_ARROW);
  408.     }
  409.  
  410.     // Identity
  411.     Keyboard.print(identity);
  412.     Keyboard.write(KEY_TAB);
  413.     Keyboard.print(wifi_pass);
  414.     repeatKey(KEY_TAB, 2);
  415.  
  416.     // Anonymous Identity
  417.     Keyboard.print(anonymousIdentity);
  418.     repeatKey(KEY_TAB, 2);
  419.   } else if (eapMethod ==  "EAP-TLS") {
  420.     // Select EAP-TLS method
  421.     repeatKey(KEY_DOWN_ARROW, 3);
  422.     Keyboard.write(KEY_TAB);
  423.  
  424.     // Server CA Certificate
  425.     if (serverCaCertificateCheck) {
  426.       Keyboard.write(KEY_DOWN_ARROW);
  427.     }
  428.     Keyboard.write(KEY_TAB);
  429.  
  430.     // Subject match
  431.     Keyboard.print(subjectMatch);
  432.     Keyboard.write(KEY_TAB);
  433.  
  434.     // Identity
  435.     Keyboard.print(identity);
  436.     repeatKey(KEY_TAB, 3);
  437.  
  438.     // Anonymous Identity
  439.     Keyboard.print(anonymousIdentity);
  440.     repeatKey(KEY_TAB, 2);
  441.   }
  442. }
  443.  
  444. void updateViaGuest(){ // Guest mode not available after enrollment keys pressed
  445.   wait(3);
  446.   repeatKey(KEY_TAB, 6); // from "Enter Email Address"
  447.   wait(2);
  448.   Keyboard.write(KEY_ENTER);
  449.   wait(15);
  450.   newTab();
  451.   Keyboard.print("chrome://chrome");
  452.   Keyboard.write(KEY_ENTER);
  453.   wait(3);
  454.   repeatKey(KEY_TAB, 1); // Move to "Check for Updates"
  455.   wait(1);
  456.   Keyboard.write(KEY_ENTER);
  457.   wait(update_wait_time);
  458.   //exit Guest Mode
  459.   Keyboard.press(KEY_RIGHT_SHIFT);
  460.   Keyboard.press(KEY_RIGHT_ALT);
  461.   Keyboard.print("s");
  462.   wait(1);
  463.   Keyboard.release(KEY_RIGHT_SHIFT);
  464.   Keyboard.release(KEY_RIGHT_ALT);
  465.   wait(1);
  466.   Keyboard.write(KEY_TAB);
  467.   wait(1);
  468.   Keyboard.write(KEY_ENTER);
  469.   wait(15);
  470. //  enterEnrollment(); // Comment out to prevent enrolling after guestmode;
  471.   wait(2);
  472. }
  473.  
  474. void reloadPolicies(){
  475.   wait(3);
  476.   newTab();
  477.   Keyboard.print("chrome://policy");
  478.   Keyboard.write(KEY_ENTER);
  479.   wait(2);
  480.   repeatKey(KEY_TAB, 1);
  481.   wait(1);
  482.   Keyboard.write(KEY_ENTER);
  483.   wait(1);
  484.   closeTab();
  485. }
  486.  
  487. void removeEnrollmentWifi(){
  488.   wait(7);
  489.   reloadPolicies();
  490.   newTab();
  491.   Keyboard.print("chrome://settings/knownNetworks?type=WiFi");
  492.   Keyboard.write(KEY_ENTER);
  493.   wait(5);
  494.   repeatKey(KEY_TAB, 3); // Select the Top Network's "More options"
  495.   wait(1);
  496.   Keyboard.write(KEY_ENTER);
  497.   wait(2);
  498.   repeatKey(KEY_DOWN_ARROW, 3); // Select "Forget";
  499.   wait(2);
  500.   Keyboard.write(KEY_ENTER);
  501.   wait(5);
  502.   closeTab();
  503. }
  504.  
  505. void newTab(){
  506.   Keyboard.press(KEY_RIGHT_CTRL);
  507.   Keyboard.print("n");
  508.   wait(1);
  509.   Keyboard.release(KEY_RIGHT_CTRL);
  510.   wait(2);
  511. }
  512. void closeTab(){
  513.   Keyboard.press(KEY_RIGHT_CTRL);
  514.   Keyboard.print("w");
  515.   wait(1);
  516.   Keyboard.release(KEY_RIGHT_CTRL);
  517.   wait(1);
  518. }
  519. void showVersion(){
  520.   Keyboard.press(KEY_RIGHT_ALT);
  521.   Keyboard.print("v");
  522.   wait(1);
  523.   Keyboard.release(KEY_RIGHT_ALT);
  524. }
  525. void Powerwash(){
  526.   Keyboard.press(KEY_RIGHT_SHIFT);
  527.   Keyboard.press(KEY_RIGHT_CTRL);
  528.   Keyboard.press(KEY_RIGHT_ALT);
  529.   Keyboard.print("r");
  530.   wait(1);
  531.   Keyboard.release(KEY_RIGHT_SHIFT);
  532.   Keyboard.release(KEY_RIGHT_CTRL);
  533.   Keyboard.release(KEY_RIGHT_ALT);
  534.   wait(1);
  535.   Keyboard.write(KEY_ENTER);
  536.   wait(2);
  537.   Keyboard.write(KEY_TAB);
  538.   Keyboard.write(KEY_ENTER);
  539. }
  540. void certificateEnrollment() {
  541.   wait(5);
  542.   repeatKey(KEY_TAB, 2);
  543.   Keyboard.print(username); //Enter Username for Certificate Enrollment
  544.   Keyboard.write(KEY_TAB);
  545.   wait(1);
  546.   Keyboard.print(password); //Enter Password for Certificate Enrollment
  547.   Keyboard.write(KEY_TAB);
  548.   wait(1);
  549.   Keyboard.write(KEY_ENTER); //Enable Device Wide certificate for Certificate Enrollment
  550.   wait(1);
  551.   repeatKey(KEY_TAB, 4);
  552.   wait(1);
  553.   Keyboard.write(KEY_ENTER);
  554.   wait(40);
  555. }
  556. void setPrescaler() {
  557.   // Disable interrupts.
  558.   uint8_t oldSREG = SREG;
  559.   cli();
  560.  
  561.   // Enable change.
  562.   CLKPR = _BV(CLKPCE); // write the CLKPCE bit to one and all the other to zero
  563.  
  564.   // Change clock division.
  565.   CLKPR = 0x0; // write the CLKPS0..3 bits while writing the CLKPE bit to zero
  566.  
  567.   // Copy for fast access.
  568.   __clock_prescaler = 0x0;
  569.  
  570.   // Recopy interrupt register.
  571.   SREG = oldSREG;
  572. }
  573.  
  574. //TODO:
  575. #define in_developer_mode 0 // Set to 1 if device is in developer mode
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top