ClamAV를 사용하여 사용자가 업로드하는 바이러스 검사 파일 방법
3524 단어 nodevirussecurityjavascript
docker pull clamav/clamav:0.105.1
docker volume create clam_db
docker run --interactive --tty --restart=always --name "clam_container_01" --publish 3310:3310 \
--publish 7357:7357 \
--mount source=clam_db,target=/var/lib/clamav \
--env 'CLAMAV_NO_FRESHCLAMD=true' \
clamav/clamav:0.105.1
이렇게 하면 ClamAV 도커 컨테이너를 가져오고, 영구 도커 볼륨을 생성하고, 포트 7357 및 3310이 노출된 ClamAV 도커 컨테이너를 실행하고, Linode가 다시 시작될 때 도커 컨테이너가 자동으로 다시 시작되도록 설정하고, clam_db라는 영구 도커 볼륨에 바이러스 정의를 유지합니다. .
이 작업을 완료한 후 패키지를 사용하여 nodejs에서 바이러스를 검색했습니다.
https://www.npmjs.com/package/clamscan
예를 들어 여기에 나를 위해 일한 것이 있습니다.
npm install clamscan
const NodeClam = require(‘clamscan’)
const ClamScan = new NodeClam().init({
removeInfected: true, // If true, removes infected files
debugMode: false, // Whether or not to log info/debug/error msgs to the console
scanRecursively: true, // If true, deep scan folders recursively
clamdscan: {
host: ‘111.111.111.11’, // IP of host to connect to TCP interface
port: 3310, // Port of host to use when connecting via TCP interface
timeout: 60000, // Timeout for scanning files
localFallback: false, // Use local preferred binary to scan if socket/tcp fails
multiscan: true, // Scan using all available cores! Yay!
active: true, // If true, this module will consider using the clamdscan binary
bypassTest: false, // Check to see if socket is available when applicable
},
preference: ‘clamdscan’, // If clamdscan is found and active, it will be used by default
})
// Get instance by resolving ClamScan promise object
ClamScan.then(async (clamscan) => {
try {
// You can re-use the `clamscan` object as many times as you want
const version = await clamscan.getVersion()
console.log(`ClamAV Version: ${version}`)
const { isInfected, file, viruses } = await clamscan.isInfected(‘./lib/virus.txt’)
if (isInfected) console.log(`${file} is infected with ${viruses}!`)
} catch (err) {
// Handle any errors raised by the code in the try block
throw err
}
}).catch(console.error)
virus.txt
의 내용에는 모든 것이 제대로 작동하는지 확인하는 데 도움이 되는 바이러스 서명이 포함되어 있습니다.X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*
실행할 때
node virus_scan.js
표시되어야 합니다.null is infected with Eicar-Signature!
여기에서 사용자가 업로드한 파일을 스캔하는 방법을 상상할 수 있어야 합니다. 귀하의 사용 사례에 상당히 고유하기 때문에 자세히 설명하지 않겠습니다.
Reference
이 문제에 관하여(ClamAV를 사용하여 사용자가 업로드하는 바이러스 검사 파일 방법), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/jfbloom22/how-to-virus-scan-file-users-upload-using-clamav-2i5d텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)