
telfhash는 ELF 파일을 위한 심볼 해시로, imphash가 PE 파일의 임포트 해시인 것과 같습니다. telfhash를 사용하면 심볼을 기반으로 ELF 파일을 유사성에 따라 클러스터링할 수 있습니다. 이는 악성 샘플을 클러스터링하는 데 특히 유용합니다. 샘플에 심볼이 없는 경우, telfhash는 호출 주소 목적지를 사용하여 심볼 목록을 에뮬레이트합니다. 자세한 내용은 리소스 섹션을 참조하십시오.
telfhash를 설치하는 가장 쉬운 방법은 pip를 이용하는 것입니다:
pip install telfhash
telfhash는 해시 생성에 TLSH를 사용합니다. telfhash가 작동하려면 시스템에 TLSH가 설치되어 있어야 합니다.
다음에서 TLSH를 설치할 수 있습니다:
TLSH git 저장소에는 TLSH 바이너리와 라이브러리를 컴파일하고 설치하는 방법에 대한 자세한 지침이 있습니다. TLSH Python 라이브러리도 설치하는 것을 잊지 마십시오. telfhash는 실제 해시를 생성하기 위해 TLSH Python 라이브러리를 사용합니다.
다음에서 telfhash 저장소를 클론하십시오:
setup.py를 사용하여 telfhash 라이브러리를 설치하십시오:
python setup.py install
telfhash가 python setup.py install 명령으로 설치된 경우, telfhash 실행 파일이 사용 가능하게 됩니다.
$ telfhash -h
usage: telfhash.py [-h] [-g] [-t THRESHOLD] [-r] [-d] files [files ...]
positional arguments:
files Target ELF file(s). Accepts wildcards
optional arguments:
-h, --help show this help message and exit
-g, --group Group the files according to how close their telfhashes
are
-t THRESHOLD, --threshold THRESHOLD
Minimum distance betweeen telfhashes to be considered
as related. Only works with -g/--group. Defaults to 50
-r, --recursive Deep dive into all the subfolders. Input should be a
folder
-d, --debug Print debug messages
$ telfhash /bin/trace*
/bin/tracepath 09d097025c0b40af18cb0c08ac3f2f5df100d850483bc1404f108809113290a2d6ae4f
/bin/traceroute 65e02002d9b9552f56f35e709caf6fa57115f841e83b87148f04b592c023542ed0549f
/bin/traceroute6 65e02002d9b9552f56f35e709caf6fa57115f841e83b87148f04b592c023542ed0549f
$ telfhash -g /sbin/ip*
/sbin/ip 33c15268ac66484d58be0e68ed2d7e68c25b5b97edf02b10dff4c412d2c3586725f01b
/sbin/ip6tables 083169fc5722ee8734bfb9357cf23b41a5092db0b9a8d0a95d08d743464636ca143c66
/sbin/ip6tables-legacy 083169fc5722ee8734bfb9357cf23b41a5092db0b9a8d0a95d08d743464636ca143c66
/sbin/ip6tables-legacy-restore 083169fc5722ee8734bfb9357cf23b41a5092db0b9a8d0a95d08d743464636ca143c66
/sbin/ip6tables-legacy-save 083169fc5722ee8734bfb9357cf23b41a5092db0b9a8d0a95d08d743464636ca143c66
/sbin/ip6tables-restore 083169fc5722ee8734bfb9357cf23b41a5092db0b9a8d0a95d08d743464636ca143c66
/sbin/ip6tables-save 083169fc5722ee8734bfb9357cf23b41a5092db0b9a8d0a95d08d743464636ca143c66
/sbin/ipmaddr 7dc08c0a6622ad4b2af66e781c3322864248e073b06ccb56aaaf854088062091c6011c
/sbin/ipset e4a0029085e66bce4ed2146959136540409454e38028d780613002a6d70154d5023d6a
/sbin/iptables 083169fc5722ee8734bfb9357cf23b41a5092db0b9a8d0a95d08d743464636ca143c66
/sbin/iptables-apply -
/sbin/iptables-legacy 083169fc5722ee8734bfb9357cf23b41a5092db0b9a8d0a95d08d743464636ca143c66
/sbin/iptables-legacy-restore 083169fc5722ee8734bfb9357cf23b41a5092db0b9a8d0a95d08d743464636ca143c66
/sbin/iptables-legacy-save 083169fc5722ee8734bfb9357cf23b41a5092db0b9a8d0a95d08d743464636ca143c66
/sbin/iptables-restore 083169fc5722ee8734bfb9357cf23b41a5092db0b9a8d0a95d08d743464636ca143c66
/sbin/iptables-save 083169fc5722ee8734bfb9357cf23b41a5092db0b9a8d0a95d08d743464636ca143c66
/sbin/iptstate 1ef02223f4318ca385920c9910f975a131268721a1dbb80dff038e758bad21e65718cf
/sbin/iptunnel d5c08c4aa612ad5b3ae72e781c3330868248e0b2b05c8b52aa2a854089062090c60518
Group 1:
/sbin/ipmaddr
/sbin/iptunnel
Group 2:
/sbin/ip6tables
/sbin/ip6tables-legacy
/sbin/ip6tables-legacy-restore
/sbin/ip6tables-legacy-save
/sbin/ip6tables-restore
/sbin/ip6tables-save
/sbin/iptables
/sbin/iptables-legacy
/sbin/iptables-legacy-restore
/sbin/iptables-legacy-save
/sbin/iptables-restore
/sbin/iptables-save
Cannot be grouped:
/sbin/iptstate
/sbin/ipset
/sbin/ip
>>> import telfhash
>>> import pprint
>>> telfhash.telfhash("/bin/ping")
{'file': '/bin/ping', 'telfhash': '6901d303587a847f9aa30ce44c3f3f5c6101e9525eb2d354cf1297948022b40aa4a99f', 'msg': ''}
>>>
>>> results = telfhash.telfhash("telfhash/tests/samples/hdumps/*")
>>> groups = telfhash.group(results)
>>> pprint.pprint(groups)
{'grouped': (('telfhash/tests/samples/hdumps/hdump_32_so_stat_stripped',
'telfhash/tests/samples/hdumps/hdump_32_stat_stripped'),
('telfhash/tests/samples/hdumps/hdump_64_so_stat_stripped',
'telfhash/tests/samples/hdumps/hdump_64_stat_stripped'),
('telfhash/tests/samples/hdumps/hdump_32_so_stat',
'telfhash/tests/samples/hdumps/hdump_32_stat',
'telfhash/tests/samples/hdumps/hdump_64_so_stat',
'telfhash/tests/samples/hdumps/hdump_64_stat',
'telfhash/tests/samples/hdumps/hdump_static'),
('telfhash/tests/samples/hdumps/hdump',
'telfhash/tests/samples/hdumps/hdump32',
'telfhash/tests/samples/hdumps/hdump_32_dyn',
'telfhash/tests/samples/hdumps/hdump_32_dyn_stripped',
'telfhash/tests/samples/hdumps/hdump_32_so_dyn',
'telfhash/tests/samples/hdumps/hdump_32_so_dyn_stripped',
'telfhash/tests/samples/hdumps/hdump_64_dyn',
'telfhash/tests/samples/hdumps/hdump_64_dyn_stripped',
'telfhash/tests/samples/hdumps/hdump_64_so_dyn',
'telfhash/tests/samples/hdumps/hdump_64_so_dyn_stripped',
'telfhash/tests/samples/hdumps/hdump_dynamic',
'telfhash/tests/samples/hdumps/hdump_stripped')),
'nogroup': []}
>>>
>>> telfhash.telfhash("samples/LinuxMoose/LinuxMoose.arm7.2015.0.bin")
{'file': 'samples/LinuxMoose/LinuxMoose.arm7.2015.0.bin', 'telfhash': None, 'msg': 'No symbols found'}
>>> telfhash.telfhash("/bin/ls", "/bin/lsattr")
[{'file': '/bin/ls', 'telfhash': '1ff0994248230af71762c8b15c0533da9a208b2656e5bf302f1985d04e2a5be779284f', 'msg': ''}, {'file': '/bin/lsattr', 'telfhash': '69c08017dd0fe4f35dd90d589c07380ae7dee06057b9d7400d3c46c1755058c5d5555d', 'msg': ''}]