كيف أحذف ملف صورة المستخدم الرمزية؟

This is the goal that I have no idea how to achieve. As an iOS reverse engineer, my idea is that if I know in the source code how/where the server sends this image, I can track back and see where the server loads this image locally. But I read Ruby like reading seudo code, so locating where the server sends this image becomes a great great task for me :sob: That should be a lot easier for a person who’re familiar with the source code though

إعجاب واحد (1)

In discourse/upload.rb at master · discourse/discourse · GitHub

I saw the table uploads which stored all the uploads of a user. For user Baal998 whose user ID is 1637, I then run SELECT * FROM uploads WHERE user_id = '1637'; and the result is

  id  | user_id | original_filename | filesize | width | height |                                     url                                     |         created_at         |         updated_at         |                   sha1                   | origin | retain_hours | extension | thumbnail_width | thumbnail_height | etag | secure | access_control_post_id | original_sha1 | animated | verified | verification_status 
------+---------+-------------------+----------+-------+--------+-----------------------------------------------------------------------------+----------------------------+----------------------------+------------------------------------------+--------+--------------+-----------+-----------------+------------------+------+--------+------------------------+---------------+----------+----------+---------------------
 2210 |    1637 | 2.pic.jpg         |    60610 |       |        | /uploads/default/original/2X/c/cb2188eaeecc3a648f021fa00da4734bd60ca183.jpg | 2016-08-08 09:37:13.937306 | 2018-01-05 02:38:49.498264 | cb2188eaeecc3a648f021fa00da4734bd60ca183 |        |              | jpg       |                 |                  |      | f      |                        |               |          |          |                   1
(1 row)

Which is the same to running Upload.find(user_avatar.custom_upload_id).url with rails.

My guess is that after the user uploaded avatar, discourse will do something to the original avatar file and store the optimized files in somewhere else?

إعجاب واحد (1)

In table optimized_images this row seemed suspicious

  id   |                   sha1                   | extension | width | height | upload_id |                                          url                                           | filesize | etag | version |         created_at         |         updated_at         
-------+------------------------------------------+-----------+-------+--------+-----------+----------------------------------------------------------------------------------------+----------+------+---------+----------------------------+----------------------------
 49538 | e6dc9b0d6c18f2a4c3c0d2027534d01cfc89c84e | .jpg      |   135 |    135 |      2210 | /uploads/default/optimized/2X/c/cb2188eaeecc3a648f021fa00da4734bd60ca183_2_135x135.jpg |    10968 |      |       2 | 2016-08-08 09:37:13.937306 | 2016-08-08 09:37:13.937306
(1 row)

The sha1 and filesize matches https://iosre.com/user_avatar/iosre.com/baal998/135/2210_2.png , but on server this file doesn’t exist.

root@iosre:/var/discourse/shared/standalone# ls /uploads/default/optimized/2X/c/cb2188eaeecc3a648f021fa00da4734bd60ca183_2_135x135.jpg
ls: cannot access /uploads/default/optimized/2X/c/cb2188eaeecc3a648f021fa00da4734bd60ca183_2_135x135.jpg: No such file or directory

No idea what was wrong.

Problem solved:

Someone from my forum told me that this avatar image might be stored in nginx cache under proxy_cache_path, which was usually /var/nginx/cache, but I couldn’t find either proxy_cache_path or /var/nginx/cache.

I was inspired by him that I entered the discourse app via launcher enter app and then found nginx cache:

root@iosre:/var/discourse/shared# /var/discourse/launcher enter app
WARNING: Docker version 17.05.0-ce deprecated, recommend upgrade to 17.06.2 or newer.
root@iosre-app:/var/www/discourse# cd /var/nginx/cache
root@iosre-app:/var/nginx/cache# ls
0  1  2  3  4  5  6  7	8  9  a  b  c  d  e  f
root@iosre-app:/var/nginx/cache# 

And deleted all the caches:

root@iosre-app:/var/nginx/cache# ls
root@iosre-app:/var/nginx/cache# 

The image was gone.

6 إعجابات

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.