Jump to content

Recommended Posts

Hi,

I'm using the code below to retrieve a file into a microcontroller running micropython.

I understand I'm open for easy attacks so, I appreciate some inputs.

TIA

<?php
  $file = $_GET['file'];
  $dir = getcwd();
  $file = $dir.'/'.$file;
  $myfile = fopen($file, "r") or die("FAIL");
  echo file_get_contents($file);
  fclose($myfile);
?>

 

Edited by ebolisa
Link to comment
https://forums.phpfreaks.com/topic/314631-security-question/
Share on other sites

29 minutes ago, gw1500se said:

What kind of attacks? Based on what you posted I am guessing you mean man-in-the-middle attacks. Once it is on either machine it is a different security issue.

The microcontroller code checks for updates, every so often. If a new firmware is available, it's downloaded.

I was wondering if any risks can exist by someone hacking the firmware code which is in Python and stored on a public web site "https://mysite.net/iot/".

Link to comment
https://forums.phpfreaks.com/topic/314631-security-question/#findComment-1594606
Share on other sites

That is a different question from what you originally asked about downloading a file. Whether or not your microcontroller is hacakble is independent of downloading an update. Assuming, of course, that you can trust the download site. Whether or not is can be hacked depends on how well you secure the microcontroller in general. Since you mentioned Python, is it running Raspbian?

Link to comment
https://forums.phpfreaks.com/topic/314631-security-question/#findComment-1594607
Share on other sites

9 minutes ago, gw1500se said:

That is a different question from what you originally asked about downloading a file. Whether or not your microcontroller is hacakble is independent of downloading an update. Assuming, of course, that you can trust the download site. Whether or not is can be hacked depends on how well you secure the microcontroller in general. Since you mentioned Python, is it running Raspbian?

A new firmware is stored on my ISP. The microcontroller is using micropython to request and download, through the php code, the new firmware. My concern is if the php code is hacakble to a pont to modify my firmware code.

Link to comment
https://forums.phpfreaks.com/topic/314631-security-question/#findComment-1594608
Share on other sites

49 minutes ago, requinix said:

What's the name of your PHP file? Let's pretend it's get.php. What do you see if you go to

/get.php?file=get.php

 

I see the content of the file: https://www.mysite.net/ota/get_ESP_data.php?file=program.py

Edited by requinix
fixing link
Link to comment
https://forums.phpfreaks.com/topic/314631-security-question/#findComment-1594611
Share on other sites

39 minutes ago, requinix said:

Not what I'm saying. What if you go to

https://www.mysite.net/ota/delete_ESP_data.php?file=delete_ESP_data.php

 

It deletes the file shown below which I call once the new firmware (https://www.mysite.net/ota/delete_ESP_data.php?file=program.py) is downloaded and stored on the microcontroller.

<?php
  $file = $_GET['file'];
  $dir = getcwd();
  $file = $dir.'/'.$file;
  unlink($file);
?>

 

Edited by ebolisa
Link to comment
https://forums.phpfreaks.com/topic/314631-security-question/#findComment-1594614
Share on other sites

You're not listening to me.

I'm not asking you to describe what happens when you run either of these scripts. I'm asking you to actually run the URLs I'm telling you about and see what happens.

Because the answer to your original question of "are there security problems here" is a very definite "yes", and I had hoped that the easiest way to tell you about it would be for you to watch it happen yourself.

Link to comment
https://forums.phpfreaks.com/topic/314631-security-question/#findComment-1594615
Share on other sites

1 minute ago, requinix said:

You're not listening to me.

I'm not asking you to describe what happens when you run either of these scripts. I'm asking you to actually run the URLs I'm telling you about and see what happens.

Because the answer to your original question of "are there security problems here" is a very definite "yes", and I had hoped that the easiest way to tell you about it would be for you to watch it happen yourself.

😄Thanks!! I realized what happened to the code when I ran the URL.

Link to comment
https://forums.phpfreaks.com/topic/314631-security-question/#findComment-1594616
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.