From f2b8b06280fb4a88509f014e35f610e458632f66 Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Mon, 10 Oct 2022 23:30:51 +0200 Subject: Fixed and improved Shell script detection --- src/tools/fileutils.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/tools/fileutils.c b/src/tools/fileutils.c index 42524ee8..c9765740 100755 --- a/src/tools/fileutils.c +++ b/src/tools/fileutils.c @@ -19,6 +19,7 @@ static const char* x86lib = "\x7f" "ELF" "\x01" "\x01" "\x01" "\x03" "\x00" "\x static const char* x64lib = "\x7f" "ELF" "\x02" "\x01" "\x01" "\x03" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x02" "\x00" "\x3e" "\x00"; static const char* bashsign= "#!/bin/bash"; static const char* shsign = "#!/bin/sh"; +static const char* bashsign2="#!/usr/bin/env bash"; int FileExist(const char* filename, int flags) { @@ -109,10 +110,13 @@ int FileIsShell(const char* filename) fclose(f); if(sz!=1) return 0; - head[strlen(bashsign)+1] = 0; + head[strlen(bashsign2)] = 0; + if(!strcmp(head, bashsign2)) + return 1; + head[strlen(bashsign)] = 0; if(!strcmp(head, bashsign)) return 1; - head[strlen(shsign)+1] = 0; + head[strlen(shsign)] = 0; if(!strcmp(head, shsign)) return 1; return 0; -- cgit 1.4.1