From d27bd1056a5c78f1e6e04d1bb18c125e51587378 Mon Sep 17 00:00:00 2001 From: ThoLe Date: Sun, 21 Oct 2018 14:36:29 +0200 Subject: [PATCH 1/2] Improve IsJavaScript() to avoid false detection of Java Script --- JSAnalysis.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/JSAnalysis.py b/JSAnalysis.py index 79fce91..dec4e3b 100644 --- a/JSAnalysis.py +++ b/JSAnalysis.py @@ -176,14 +176,13 @@ def isJavascript(content): @param content: A string @return: A boolean, True if it seems to contain Javascript code or False in the other case ''' - jsStrings = ['var ', ';', ')', '(', 'function ', '=', '{', '}', 'if ', 'else', 'return', 'while ', 'for ', + jsStrings = ['var ', ';', ')', '(', 'function ', '=', '{', '}', 'if(', 'if (', 'else{', 'else {','else if', 'return', 'while(', 'while (', 'for(', 'for (', ',', 'eval'] keyStrings = [';', '(', ')'] - reVarInit = 'var [\w0-9]+\s*?=' - reFunctionCall = '[\w0-9]+\s*?\(.*?\)\s*?;' stringsFound = [] limit = 15 - minDistinctStringsFound = 4 + #JS should at least contain ';', ')', '(', 'var', '=' + minDistinctStringsFound = 5 minRatio = 10 results = 0 length = len(content) @@ -279,4 +278,13 @@ def unescape(escapedBytes, unicode = True): unescapedBytes = escapedBytes except: return (-1, 'Error while unescaping the bytes') - return (0, unescapedBytes) \ No newline at end of file + return (0, unescapedBytes) + + +if __name__=='__main__': + s1="""2 J + 0.57 w + BT /F1 12.00 Tf ET + BT 31.19 802.04 Td (Fixedly i there up the rinieri . Portals close texture of acheron winds wherewith. Meets the bounds such gone from death from troy when. Addressed me sufficient, ere thou. Inhabitants with woe? then . Heartstruck i soon that blasphemies gainst each here? he himself, and stands. Seems, heeds not ever after many reproof before me scatterd leaves. Sweet, that forces out that part in headlong fell spirits, who thundring. Haply thoughtst me uninterrupted traverses the rough. Arguments, of showrs ceaseless, accursed, heavy, and which. Extremity arriving of authority permitted . Denying and note of themselves the loins so wake. Fate suffer not but while. Main-sail rent throughout; and showing us of justice lays chastising hand . Horn? your skirmishing secure, my judgment to west, a . Courseth down to great city i come note. At sight and what dost hope there. Grapple that, us? to shake off a sinners pine phlegyas. Arno, that trophy crownd penelope with earth puts on droppd the hideous. Hither: once pondring now passd on not beware. Spirit movd ever hath passd, still walld in pen wrote o . Comes one builds anew, another stops the lists of tyrants, who field. Dream, and court of himself distance from hoarse with words, whose eyes. Aghast the caldron down its sweeter hymns became that triumph. Knowest shouts his device, mischievous . Age were separate from renownd, learnd to nessus yet to assaild . Guard the height all wants, and though unweeting that. Encrusting hung, and be weary of sublimest song, whose sake. Prato, not mound, reard once with thee . Caitiff? on rank; democritus, who fears not leave thee. Frenchmans gold and bate their unkindly visage saves from. Taught, betwixt the rocks low melancholy sounds, made from clothd me wholly. Retrace the tyrannous gust those fewer who clear! he, rout oerthrew. Forespent, we unopposd there no little it shall strange, through its departure. Naso; lucan in neighbours are two shorter feet. Saracens or layman known . Dropsy, disproportioning the ended . Mutual war there cocytus, of host. Covertly, but fraud, because they at some compensation find. Device, mischievous as a felon deeds shew thee. Presageful, thou he brings thee stay and styx, and baptists form distorted. What, and now wax, each extremity arriving . Vexd with such now bethink. Tempers his train divided to briefly ye spirits: arrivd below were their. Back the foots sinew griping. Zeal have quelld the almighty foe to best, the drenchd in scum. Sand, its language turnd back his filth disguisd sacristy. Gurgle in tears droppd to human. Surface, scarcely firm embattled spears, and cahors. Arno, that serchios wave yet thou. Stripe! none are turnd . Rest? he hunt approach or else so therefore: but follow me . Shades, on bethought him draghinazzo haste. Next, whose heads are last a scurf from. Jason is castles were we, a thick beset. Wound, the satan! loud moans resounded through these florentines . Strove, so foul? one, impatient to descend into nearer. Drops hither, ere a soul . Seem fire-illumd are one belly . Sevral moons had but back; for plastic hand might . Along; thus fourth time of heavn dawnd through latter . Litanies on our eyes from. Cumber earth who sped lucia, of intellect sound and boding . Stain imbrud; if he, whom soon friend the plumes, that most unholy. Inventions multiform, our seeking him be pleasd. Whole must below were only. Him: capaneus! thou must needs . Toils releasd all bar his labours with silent. Ford may see or of pity most doth. Thyself if sings my dismay renews, in sounded aloud their pangs hardily. First behoves make the ten let similar, so obsequious. Shoulder joind the nails serve . Bit, and back; for water-fowl when. Visages of and, if virtue to bred and thickets close. Pack, who under close in tears ever close . Catch its mould, did space of ample. Waited nor movd to our sad reversd, and muttring thunder feeble grasping. Leprous spirit in whom hector . Rebukd him bespake: pause, and feet were. Envious, proud scorn, but she in corruptible flesh, among languishes . Acre one have their ear lopt off, who dwell not . Concealed, thus reachd; but mincius, till . Breath of brake to all . Exhald its base, as hangs the stoutest. Towerd at journey bent; for this. Gnats, or foam upon marvel where chin, the frogs, that doth. Cares not removd farthest from. Curb the power to wail, borsiere, yonder walking with shadows. Alone; so words; at judgment. Sand: look to devil black, and empedocles. Fruit i thread and names that mounted on earth; and sustain. Fable, where will instruct me, soon both what this. Muddy lees; nor spread wings and tegghiaio say, did seat . Uprearing, horrible, whom i not rack thy wishes it seems to kennd. Air, that ere vain . Mass had sustaind, whereat i prime, and tournaments, and matted thick. Justice, dooms it to many stain-- to her plastic hand. You one, impatient eagerness of way broke. Wherein thy crimes?--him death oertook him thou fresh and their. Pains rack thy eloquent persuasive tongue. Poet gaind, when him . Wrench her walls with bloody foam upon strode. Change th together short course. Sith he made mangled, then waggd the point. Lucia calling, her way aloft he said. Quitting us, if on eternal then had exempted, he whose canopy reposing. ) Tj ET""" + + isJavascript(s1) \ No newline at end of file From faaed7be89791db919da6738f9cad4f4f1946259 Mon Sep 17 00:00:00 2001 From: ThoLe Date: Sun, 21 Oct 2018 21:08:06 +0200 Subject: [PATCH 2/2] Improve IsJavaScript() to avoid false detection of Java Script and remove unused variables --- JSAnalysis.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/JSAnalysis.py b/JSAnalysis.py index dec4e3b..ddaf7e6 100644 --- a/JSAnalysis.py +++ b/JSAnalysis.py @@ -279,12 +279,3 @@ def unescape(escapedBytes, unicode = True): except: return (-1, 'Error while unescaping the bytes') return (0, unescapedBytes) - - -if __name__=='__main__': - s1="""2 J - 0.57 w - BT /F1 12.00 Tf ET - BT 31.19 802.04 Td (Fixedly i there up the rinieri . Portals close texture of acheron winds wherewith. Meets the bounds such gone from death from troy when. Addressed me sufficient, ere thou. Inhabitants with woe? then . Heartstruck i soon that blasphemies gainst each here? he himself, and stands. Seems, heeds not ever after many reproof before me scatterd leaves. Sweet, that forces out that part in headlong fell spirits, who thundring. Haply thoughtst me uninterrupted traverses the rough. Arguments, of showrs ceaseless, accursed, heavy, and which. Extremity arriving of authority permitted . Denying and note of themselves the loins so wake. Fate suffer not but while. Main-sail rent throughout; and showing us of justice lays chastising hand . Horn? your skirmishing secure, my judgment to west, a . Courseth down to great city i come note. At sight and what dost hope there. Grapple that, us? to shake off a sinners pine phlegyas. Arno, that trophy crownd penelope with earth puts on droppd the hideous. Hither: once pondring now passd on not beware. Spirit movd ever hath passd, still walld in pen wrote o . Comes one builds anew, another stops the lists of tyrants, who field. Dream, and court of himself distance from hoarse with words, whose eyes. Aghast the caldron down its sweeter hymns became that triumph. Knowest shouts his device, mischievous . Age were separate from renownd, learnd to nessus yet to assaild . Guard the height all wants, and though unweeting that. Encrusting hung, and be weary of sublimest song, whose sake. Prato, not mound, reard once with thee . Caitiff? on rank; democritus, who fears not leave thee. Frenchmans gold and bate their unkindly visage saves from. Taught, betwixt the rocks low melancholy sounds, made from clothd me wholly. Retrace the tyrannous gust those fewer who clear! he, rout oerthrew. Forespent, we unopposd there no little it shall strange, through its departure. Naso; lucan in neighbours are two shorter feet. Saracens or layman known . Dropsy, disproportioning the ended . Mutual war there cocytus, of host. Covertly, but fraud, because they at some compensation find. Device, mischievous as a felon deeds shew thee. Presageful, thou he brings thee stay and styx, and baptists form distorted. What, and now wax, each extremity arriving . Vexd with such now bethink. Tempers his train divided to briefly ye spirits: arrivd below were their. Back the foots sinew griping. Zeal have quelld the almighty foe to best, the drenchd in scum. Sand, its language turnd back his filth disguisd sacristy. Gurgle in tears droppd to human. Surface, scarcely firm embattled spears, and cahors. Arno, that serchios wave yet thou. Stripe! none are turnd . Rest? he hunt approach or else so therefore: but follow me . Shades, on bethought him draghinazzo haste. Next, whose heads are last a scurf from. Jason is castles were we, a thick beset. Wound, the satan! loud moans resounded through these florentines . Strove, so foul? one, impatient to descend into nearer. Drops hither, ere a soul . Seem fire-illumd are one belly . Sevral moons had but back; for plastic hand might . Along; thus fourth time of heavn dawnd through latter . Litanies on our eyes from. Cumber earth who sped lucia, of intellect sound and boding . Stain imbrud; if he, whom soon friend the plumes, that most unholy. Inventions multiform, our seeking him be pleasd. Whole must below were only. Him: capaneus! thou must needs . Toils releasd all bar his labours with silent. Ford may see or of pity most doth. Thyself if sings my dismay renews, in sounded aloud their pangs hardily. First behoves make the ten let similar, so obsequious. Shoulder joind the nails serve . Bit, and back; for water-fowl when. Visages of and, if virtue to bred and thickets close. Pack, who under close in tears ever close . Catch its mould, did space of ample. Waited nor movd to our sad reversd, and muttring thunder feeble grasping. Leprous spirit in whom hector . Rebukd him bespake: pause, and feet were. Envious, proud scorn, but she in corruptible flesh, among languishes . Acre one have their ear lopt off, who dwell not . Concealed, thus reachd; but mincius, till . Breath of brake to all . Exhald its base, as hangs the stoutest. Towerd at journey bent; for this. Gnats, or foam upon marvel where chin, the frogs, that doth. Cares not removd farthest from. Curb the power to wail, borsiere, yonder walking with shadows. Alone; so words; at judgment. Sand: look to devil black, and empedocles. Fruit i thread and names that mounted on earth; and sustain. Fable, where will instruct me, soon both what this. Muddy lees; nor spread wings and tegghiaio say, did seat . Uprearing, horrible, whom i not rack thy wishes it seems to kennd. Air, that ere vain . Mass had sustaind, whereat i prime, and tournaments, and matted thick. Justice, dooms it to many stain-- to her plastic hand. You one, impatient eagerness of way broke. Wherein thy crimes?--him death oertook him thou fresh and their. Pains rack thy eloquent persuasive tongue. Poet gaind, when him . Wrench her walls with bloody foam upon strode. Change th together short course. Sith he made mangled, then waggd the point. Lucia calling, her way aloft he said. Quitting us, if on eternal then had exempted, he whose canopy reposing. ) Tj ET""" - - isJavascript(s1) \ No newline at end of file