++++🔥 ความปลอดภัยกับการโค้ดดิ่ง 🔥+++
การเขียนหน้าเว็บ ที่มีแบบฟอร์มให้กดอัพโหลดไฟล์
...พอกด upload
...ไฟล์นั้นจะถูกนำไปวางบน server ปั๊บ
.
ถ้าเราเขียนโค้ดฝั่ง server ไม่ระมัดระวัง ตัวละก็ ...ฮึๆๆๆ
ก็จะมีรูรั่ว เมื่อhacker เห็น
ก็จะยิ้มหน้าบานเป็นจานดาวเทียม
เขาสามารถโจมตีช่องโหว่ได้ไม่ยากเย็นอะไรนัก
.
ซึ่งจะขอยกตัวอย่างภาษา PHP มาเป็นกรณีศึกษาแล้วกัน
:
😉 สำหรับวิธีโจมตีนี้
อาศัยความง่ายของ php ที่แค่วางไฟล์บน server ในทันใด
เราก็สามารถเรียกไฟล์นั้น ผ่าน url ให้ทำงานได้เลย ในทันที
...ดูง่ายมั๊ยละ!!!!!
.
*** หมายเหตุ แต่ถ้าเป็นภาษาโปรแกรมมิ่งบางภาษา
ที่เข้มงวดความปลอดภัย
การโจมตีแบบนี้จะยาก
เพราะโปรแกรมเมอร์ต้อง config ไฟล์สคริปต์ก่อน
สคริปต์นั้นถึงจะประมวลผลได้
:
:
แต่ในโพสต์นี้จะขอยกตัวอย่างโค้ด PHP ที่มีช่องโหว่นะครับ
ก็ตามรูปที่โพสต์ จะประกอบไปด้วย
:
1) หน้าฟอร์ม HTML (index.html) เอาไว้ให้อัพโหลดไฟล์ (ฝั่ง browser)
2) เมื่อ user กดอัพโหลดไฟล์ ...ไฟล์นั้นจะถูกส่งไปยัง server
3) ฝั่ง server จะใช้ภาษา PHP ง่ายๆ (upload.php) รับไฟล์ที่ส่งเข้ามา แล้วนำไปวางไว้ที่โฟล์เดอร์ใดที่หนึ่งในเครื่อง เช่น uploads
:
😱 ซึ่งการเขียนโค้ดที่ง่ายเกิ๊นไปเช่นนี้
จะเป็นช่องโหว่ให้ hacker
สามารถอัพโหลดไฟล์อันตรายขึ้นไปวางบน server ได้ชิวๆๆ
:
🤔 ดังนั้นเราต้องป้องกันการโจมตีด้วยวิธีนี้ อาทิ
- ต้องเข้มงวดเรื่องนามสกุลไฟล์ว่า ไฟล์ชนิดอะไรที่ห้าม upload (เช่น .php ห้ามทำเด็ดขาด)
- หรือจะใช้ API หรือไลบรารี่ ทำการเชคไฟล์ให้ดีๆ ว่ามีชนิดถูกต้อง
- เชค contet-type ใน header request
- จำกัดขนาดไฟล์ รวมทั้งตรวจสอบชื่อไฟล์ดีๆ
- ไดเรคทอรี่ที่จะอัพโหลดไฟล์ขึ้นไปวาง ควรไม่มีสิทธิในการรันสคริปต์ใดๆ
- ฝั่ง server ควรติดตั้งซอฟต์แวร์ scanner เอาไว้สแกนหาไฟล์แปลกปลอมของ hacker ที่หลอกเข้ามาฝั่งตัว
- ในหน้าฟอร์ม (HTML) เปลี่ยนวิธีส่ง request จากเดิม ที่ใช้ put หรือ get ให้หันมาใช้วิธี post แทน
- และวิธีการอื่นๆ ที่ไม่ได้กล่าวถึง
+++++++++++++++
เขียนโดย โปรแกรมเมอร์ไทย thai programmer
รักกันก็กระทืบ like ชังกันอย่าด่าเยอะมันเจ็บ
.
รายละเอียดเพิ่มเติม
https://www.defensecode.com/…/web_vul…/form-file-upload.html
.
++++ ++++ Safety with the code 🔥 +++
Writing pages with forms to upload files
... Poke upload
... That file will be put on a pump server
.
If we write server side code, I'm not careful. I'm not careful. Haha.
There will be a leak when hacker sees it
I'll smile on my face as a satellite dish
He can attack the loophole. It's not that difficult.
.
Which one would like to sample PHP language as a case study.
:
😉 for how to attack this
Live the simplicity of php that just puts a file on server instantly.
We can call that file through url to work instantly.
... How easy is it!!!!!
.
*** note but if it's some programming language
Safety strictly
This kind of attack will be hard.
Because the programmer has to config the script file first.
That script is processed.
:
:
But in this post, I will give you an example of a PHP code that has a loophole.
As photos posted will include.
:
1) HTML (index. html) to upload file (browser side)
2) When user presses upload file... that file will be sent to server.
3) server side will use PHP language simply (upload. php) Receive the file sent in and put it on a folder of any of the devices such as uploads.
:
😱 Which one of these simple code writing goes like this?
Gonna be a loophole for hacker
Can upload a dangerous file to place on server. Chilling.
:
🤔 So we need to prevent attack this way. This week.
- Must be strict on file extensions. What type of file that cannot upload (e.g.. php don't do it.)
- or use API or Library to check your file correctly.
- contet-type shake in header request
- limit file size and check good file name
- Directory to upload file over to lay should not have any script running rights.
- server side should install scanner software to scan for foreign file of hacker who has tricked into his side.
- In the form (HTML), change the way to send request from the original put or get, turn to the post method instead.
- And other ways not mentioned
+++++++++++++++
Written by Thai programmer thai coder
If you love each other, stomp like each other. Don't scold too much. It hurts.
.
More details.
https://www.defensecode.com/public/web_vulns/form-file-upload.html
.Translated
同時也有10000部Youtube影片,追蹤數超過2,910的網紅コバにゃんチャンネル,也在其Youtube影片中提到,...
「html include header」的推薦目錄:
- 關於html include header 在 โปรแกรมเมอร์ไทย Thai programmer Facebook 的最讚貼文
- 關於html include header 在 コバにゃんチャンネル Youtube 的精選貼文
- 關於html include header 在 大象中醫 Youtube 的最讚貼文
- 關於html include header 在 大象中醫 Youtube 的精選貼文
- 關於html include header 在 Make header and footer files to be included ... - Stack Overflow 的評價
- 關於html include header 在 Include header and footer html files into another html file ... 的評價
- 關於html include header 在 Issues - GitHub 的評價
- 關於html include header 在 Including header and footer into every HTML file - YouTube 的評價
- 關於html include header 在 Google C++ Style Guide 的評價
html include header 在 Include header and footer html files into another html file ... 的推薦與評價
Here's how you would do it with php. <html> <body> <h1>Welcome to my home page!</h1> <p>Some text.</p> <p>Some more text.</p> <?php include ... ... <看更多>
html include header 在 Issues - GitHub 的推薦與評價
The requirement to use javascript to insert HTML snippet into main ... [imports] HTML Includes (<import src='header.html'/> in <body>) #280. ... <看更多>
html include header 在 Make header and footer files to be included ... - Stack Overflow 的推薦與評價
... <看更多>
相關內容