การโจมตีด้วยการอัปโหลดไฟล์ถือเป็นรูปแบบการโจมตีที่สำคัญในปีนี้ โดยมีจำนวนเว็บไซต์ที่ตกเป็นเหยื่อเป็นประวัติการณ์ การมีวิธีการป้องกันที่เหมาะสมเป็นสิ่งสำคัญหากคุณต้องการหลีกเลี่ยงชะตากรรมที่คล้ายคลึงกัน น่าเสียดายที่มีวิธีการมากมายสำหรับผู้โจมตี คุณจะต้องมีวิธีการขั้นสูง วันนี้ฉันจะแสดงวิธีตั้งค่า API การสแกนไวรัสที่ช่วยให้สามารถตรวจจับภัยคุกคามขั้นสูง รวมถึงไฟล์ปฏิบัติการ สคริปต์ และอื่นๆ อีกมากมาย

ขั้นแรก เราจะต้องนำเข้าไคลเอนต์:

<script src="https://cdn.cloudmersive.com/jsclient/cloudmersive-virus-client.js"></script>

ตอนนี้เราจะดำเนินการเรียก scanFileAdvanced ต่อไป ตามค่าเริ่มต้น การดำเนินการนี้จะบล็อกไฟล์ปฏิบัติการ ไฟล์ที่ไม่ถูกต้อง ไฟล์ที่ป้องกันด้วยรหัสผ่าน และสคริปต์ รวมถึงการสแกนไวรัสที่มีความไวสูง คุณยังสามารถเลือกที่จะจำกัดอินพุตของคุณไว้เฉพาะไฟล์บางประเภทได้ ขอแนะนำให้คุณจัดเก็บไฟล์ไว้ในหน่วยความจำในขณะที่กำลังทำการสแกน

var CloudmersiveVirusApiClient = require('cloudmersive-virus-api-client');
var defaultClient = CloudmersiveVirusApiClient.ApiClient.instance;
// Configure API key authorization: Apikey
var Apikey = defaultClient.authentications['Apikey'];
Apikey.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//Apikey.apiKeyPrefix = 'Token';
var apiInstance = new CloudmersiveVirusApiClient.ScanApi();
var inputFile = "/path/to/file.txt"; // File | Input file to perform the operation on.
var opts = {
'allowExecutables': true, // Boolean | Set to false to block executable files (program code) from being allowed in the input file.  Default is false (recommended).
'allowInvalidFiles': true, // Boolean | Set to false to block invalid files, such as a PDF file that is not really a valid PDF file, or a Word Document that is not a valid Word Document.  Default is false (recommended).
'allowScripts': true, // Boolean | Set to false to block script files, such as a PHP files, Pythong scripts, and other malicious content or security threats that can be embedded in the file.  Set to true to allow these file types.  Default is false (recommended).
'allowPasswordProtectedFiles': true, // Boolean | Set to false to block password protected and encrypted files, such as encrypted zip and rar files, and other files that seek to circumvent scanning through passwords.  Set to true to allow these file types.  Default is false (recommended).
'restrictFileTypes': "restrictFileTypes_example" // String | Specify a restricted set of file formats to allow as clean as a comma-separated list of file formats, such as .pdf,.docx,.png would allow only PDF, PNG and Word document files.  All files must pass content verification against this list of file formats, if they do not, then the result will be returned as CleanResult=false.  Set restrictFileTypes parameter to null or empty string to disable; default is disabled.
};
var callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
};
apiInstance.scanFileAdvanced(inputFile, opts, callback);

เท่านี้คุณก็มีระบบรักษาความปลอดภัยขั้นสูงสำหรับการอัพโหลดไฟล์แล้ว