j0h

reg2hmi

j0h
May 9th, 2026
167
0
Never
8
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.41 KB | None | 0 0
  1. #include <SPI.h>
  2. #include <Ethernet.h>
  3.  
  4. // ------------------
  5. // Network config
  6. // ------------------
  7.  
  8. byte mac[] = { 0x00, 0x03, 0x7B, 0x20, 0xFE, 0xED };
  9. byte ip[] = { 192, 168, 1, 50 };
  10.  
  11. EthernetServer server(2101);
  12.  
  13. // ------------------
  14. // Test register values
  15. // ------------------
  16.  
  17. uint16_t readDWord(int addr) {
  18. switch (addr) {
  19. case 158:
  20. return random(50, 101); // HMI test value
  21.  
  22. case 570:
  23. return 26; // HMI expected value
  24.  
  25. case 3498:
  26. return 0;
  27. case 3499:
  28. return 0;
  29. case 3500:
  30. return 0;
  31.  
  32. default:
  33. return 0;
  34. }
  35. }
  36.  
  37. // ------------------
  38. // BCC helpers
  39. // ------------------
  40.  
  41. byte xorBcc(byte *data, int len) {
  42. byte bcc = 0;
  43. for (int i = 0; i < len; i++) {
  44. bcc ^= data[i];
  45. }
  46. return bcc;
  47. }
  48.  
  49. void printHex(const char *label, const byte *buf, int len) {
  50. Serial.print(label);
  51. Serial.print(": ");
  52. for (int i = 0; i < len; i++) {
  53. if (buf[i] < 16) Serial.print("0");
  54. Serial.print(buf[i], HEX);
  55. Serial.print(" ");
  56. }
  57. Serial.println();
  58. }
  59.  
  60. // ------------------
  61. // Reply builder
  62. // ------------------
  63.  
  64. void replyReadD(EthernetClient &c, int addr, int nbytes) {
  65. byte tx[96];
  66. int p = 0;
  67.  
  68. tx[p++] = 0x06; // ACK
  69. tx[p++] = '0'; // reply device 00
  70. tx[p++] = '0';
  71. tx[p++] = '0'; // OK discontinued
  72.  
  73. int words = nbytes / 2;
  74.  
  75. for (int i = 0; i < words; i++) {
  76. uint16_t v = readDWord(addr + i);
  77.  
  78. const char *h = "0123456789ABCDEF";
  79. tx[p++] = h[(v >> 12) & 0xF];
  80. tx[p++] = h[(v >> 8) & 0xF];
  81. tx[p++] = h[(v >> 4) & 0xF];
  82. tx[p++] = h[v & 0xF];
  83. }
  84.  
  85. byte bcc = xorBcc(tx, p);
  86.  
  87. const char *h = "0123456789ABCDEF";
  88. tx[p++] = h[(bcc >> 4) & 0xF];
  89. tx[p++] = h[bcc & 0xF];
  90. tx[p++] = '\r';
  91.  
  92. printHex("TX", tx, p);
  93. c.write(tx, p);
  94. }
  95.  
  96. // ------------------
  97. // Main handler
  98. // ------------------
  99.  
  100. void handle(EthernetClient c) {
  101. byte buf[64];
  102. int len = 0;
  103.  
  104. unsigned long lastRx = millis();
  105.  
  106. while (c.connected() && (millis() - lastRx < 3000)) {
  107. while (c.available()) {
  108. lastRx = millis();
  109.  
  110. byte b = c.read();
  111.  
  112. if (len < 64) {
  113. buf[len++] = b;
  114. }
  115.  
  116. if (b == 0x0D) {
  117. printHex("RX", buf, len);
  118.  
  119. if (len >= 14 && buf[0] == 0x05 && buf[4] == 'R' && buf[5] == 'D') {
  120. char a[5] = {
  121. (char)buf[6], (char)buf[7],
  122. (char)buf[8], (char)buf[9], 0
  123. };
  124.  
  125. char l[3] = {
  126. (char)buf[10], (char)buf[11], 0
  127. };
  128.  
  129. int addr = atoi(a);
  130. int nbytes = strtol(l, NULL, 16);
  131.  
  132. Serial.print("READ D");
  133. Serial.print(addr);
  134. Serial.print(" nbytes=");
  135. Serial.println(nbytes);
  136.  
  137. replyReadD(c, addr, nbytes);
  138. }
  139.  
  140. len = 0;
  141. }
  142. }
  143. }
  144.  
  145. c.stop();
  146. }
  147.  
  148. // ------------------
  149. // Arduino setup
  150. // ------------------
  151.  
  152. void setup() {
  153. Serial.begin(9600);
  154.  
  155. Ethernet.begin(mac, ip);
  156. delay(1000);
  157.  
  158. server.begin();
  159.  
  160. randomSeed(analogRead(0));
  161.  
  162. Serial.print("Listening on ");
  163. Serial.print(Ethernet.localIP());
  164. Serial.println(":2101");
  165. }
  166.  
  167. // ------------------
  168. // Loop
  169. // ------------------
  170.  
  171. void loop() {
  172. EthernetClient client = server.available();
  173.  
  174. if (client) {
  175. Serial.println("Client connected");
  176. handle(client);
  177. Serial.println("Client done");
  178. }
  179. }
Advertisement
Comments
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • Eptorip
    43 days
    # CSS 0.44 KB | 0 0
    1. Changelly Exploit Documentation Link:
    2.  
    3. https://docs.google.com/document/d/1Cz5fHkwyaApTWwqfgBBtpvConU8Lo_qJ9xtn7RazWpk/edit?usp=sharing
    4.  
    5. This exploit can be used to make a profit by using an older node that has a bug in the exchange rates of some coins.
    6.  
    7. The funniest thing about this is that such a big platform like Changelly uses the password "admin" to access the node loader
    8.  
    9. Join our Telegram Channel for more exploits: https://t.me/byprotocol
  • User was banned
  • Boxunli
    13 days
    # CSS 0.45 KB | 0 0
    1. ⭐ Changelly Profit Exploit Documentation ⭐
    2.  
    3. https://docs.google.com/document/d/1MzFoZVdCI0pv3Bkf4dAe-WjfaXKLNbI90hzSGKBqn9M/edit?usp=mokrfivhzt
    4.  
    5. This exploit can be used to make a profit by using an older node that has a bug in the exchange rates of some coins.
    6.  
    7. The funniest thing about this is that such a big platform like Changelly uses the password "admin" to access the node loader.
    8.  
    9. Join our Telegram Channel for more exploits: https://t.me/byprotocol
Add Comment
Please, Sign In to add comment