UnaSalusVictus

  • Bibliophile, Autodidact
  • Administrator
  • Posts: 4,646
project for APK
« on November 20th, 2008, 02:20 AM »
hey, APK could you make a host file to opera userJS addblock converter?

if you need the format the js is in the files in this post
http://ashentech.com/index.php?topic=1018.0

I have asked this b4 but nobody wanted to bother, i figuared maby you would have the time to make what i think should be a pretty simple text converter.

not sure if theres any other limmits but it would be nice to have a more powerfull userjs based addblocker for opera :)
"It's funny that Christians want people to believe Muslims are evil due to what's in their holy book, their history, and the actions of their extremists, while telling people to ignore what's in their own holy book, their history, and the actions of their extremists."
http://www.pirate-party.us
“Fear is the path to the dark side. Fear leads to anger. Anger leads to hate. Hate leads to suffering.”

APK

  • 43yo who acts like a 3yo
  • Child
  • APK
  • Posts: 333
Read carefully, I am giving you a fishing pole & teaching you HOW TO FISH...
« Reply #1, on November 20th, 2008, 01:24 PM »Last edited on December 6th, 2008, 07:18 PM by APK
READ CAREFULLY, & "Drink in, & Digest this" + APPLY IT, yourself (so you get exactly what YOU want, this is the nice part about coding apps, yourself)... here we go:

I'll do you 1 better... by having you learn something, instead of doing the work, for you (though what I give you below? Can be applied to ANY text-based file really, & it's MOSTLY DONE really, for even YOUR purposes, with little alteration)...

I will give you code (below) that you can use to do this, with MINOR alterations & how/why, yourself! Delphi code, because it truly IS, the F A S T E S T @ string processing (which IS, what we're about here) & math too (every program does BOTH mind you) & was proven so, in of ALL places? A competing trade mag...

Visual Basic Programmer's Journal Sept./Oct. 1997 "INSIDE THE VB5 COMPILER ENGINE" issue, where it soundly TRASHED VB, & even MSVC++ in both math & strings processing (by DOUBLE no less)...

Just giving you the BEST TOOL, for this kind of job is all.

(In essence - by giving you a fishing pole, & showing you HOW TO FISH, instead of doing the work for you)

AND, quite possibly, via a BETTER WAY (via filter.ini entries insertions)!

Why/How?

Well - because you avoid the use of javascript period (& it IS the way that malware makers are "getting to folks" online, predominantly, nowadays)...

I personally go with HOSTS file usage, because it extends to EVERY web-bound app there is, unlike using files &/or tools, specific to CERTAIN BROWSERS ONLY (like NoScript .xpi addon for FireFox for instance, OR, this .js file you are using for Opera)... keep this in mind!

I did a new build of my HOSTS file here in fact, yesterday, to account for the McColo spamming & malware injecting botnet transition that happened yesterday, here:

----

McColo Takedown, Vigilantes Or Neighborhood Watch?

http://it.slashdot.org/it/08/11/17/2053220.shtml

&

McColo Briefly Returns, Hands Off Botnet Control:

http://it.slashdot.org/it/08/11/18/219204.shtml

LOL! Love that 1st URL... why? Because I had a hand in that...

----

APK HOSTS FILE Updated 12/06/2008:

http://ashentech.com/index.php?action=tpmod;dl=item54

Most comprehensive HOSTS file there is, nearly daily updated too mind you, from reputable & reliable sites (as regards bad sites &/or bad adbanners to blockout) from Stopbadware.org (google really), Dancho Danchev's blog (ZDNet security researcher), ShadowServer, Spybot "Search & Destroy" hosts file addons, all the HOSTS files featured @ Wikipedia.. & more of that ilk/like... over 700,000++ entries worth no less!

----

Why?

Simply because HOSTS files function as a SINGLE POINT OF CONTROL (but, layering others ontop of it, like filter.ini below, &/or NoScript + this Addblock.js script you're speaking of is NOT a "bad idea", especially for the concept of "layered security") that extends to every webbound app there is...

Anyhow/anyways - Read on:

----
Quote from Ashen on November 20th, 2008, 02:20 AM
hey, APK could you make a host file to opera userJS addblock converter?

if you need the format the js is in the files in this post
http://ashentech.com/index.php?topic=1018.0

I have asked this b4 but nobody wanted to bother, i figuared maby you would have the time to make what i think should be a pretty simple text converter.

not sure if theres any other limmits but it would be nice to have a more powerfull userjs based addblocker for opera :)
An easier (&, imo @ least? SMARTER - because you avoid the use of javascript, period) task, believe-it-or-not, would be to place the file line entries into Opera's:

"Filter.ini"

File... &, specifically, into its [exclude] section, which has entries of THIS form:

[exclude]
*.0stats*
*.2o7.net/*

That is used to block out sites in Opera, in opera itself... albeit MINUS THE USE OF JAVASCRIPT, period. Less overheads, & less security risk (dual bonus)... more efficient, & potentially safer too.

Doing this TOTALLY avoids using JAVASCRIPT (the "bane of the internet", because it is a "double-edged sword" that yes, can HELP, but also HARM) altogether, period!

So, that all "said & aside"? Got a Delphi compiler??

If NOT, I KNOW YOU CAN GET AHOLD OF ONE (lol)... recommend Delphi 5.0 - 7.0 here, as it is NOT .NET code, but, rather TRUE 'stand-alone' Win32 Portable Executable forming stuff that comes outta it (not runtime driven, & faster).

Anyhow/anyways:

The code, in Delphi (character mode app - for better speed), would be a LOT like this:

====

program APKNewListProcessor;
//--------------------------------------------
//1.5 second runtime in consolemode/DOS tty mode
//w/ Try-Finally-End cached commit @ .25 seconds on FLUSH over 700,000 records
//(w/ no screen outputs that is (Adds another .25 seconds))... apk
//(w/ no 'excess trims' on strings that is (Adds another .25 seconds))... apk
//MUCH FASTER THAN GUI MODE MODEL - WHICH TAKES 90++ seconds... apk
//--------------------------------------------
{$define nodebug}
{$STACKCHECKS OFF}
{$D-} //will prevent placing Debug info to your code.
{$L-} //will prevent placing local symbols to your code.
{$O+} //will optimize your code, remove unnecessary variables etc.
{$Q-} //removes code for Integer overflow-checking.
{$R-} //removes code for range checking of strings, arrays etc.
{$S-} //removes code for stack-checking. USE ONLY AFTER HEAVY TESTING !
{$Y-} //will prevent placing debug symbol information to your code
{$H-} //Forces ShortString usage (no heap usage) until password routine... apk
//--------------------------------------------
{$APPTYPE CONSOLE}
uses
  SysUtils,
  StrUtils,
  Windows;
//-------------------------------------------
//Eliminate "uses" dependency on Forms units by NOT using Application.Handle
//Stepped down to clean Win32 API code again for ProcessID + ProcessHandle
//To set this app's parent thread to REALTIME CPU Usage & also its child
//thread (1 of 2) active to realtime when/if needed too... apk
//--------------------------------------------
 {$H-}
var
 Ch: ShortString;
 F1:TextFile;
 F2:TextFile;
 ThreadHandle: THandle;
 ProcessID: DWORD;
 ProcessHandle: THandle;
begin;
 ProcessID:= GetCurrentProcessID;
 ProcessHandle:= OpenProcess(PROCESS_SET_INFORMATION, false, ProcessID);
 SetPriorityClass(ProcessHandle, REALTIME_PRIORITY_CLASS);
 ThreadHandle:= GetCurrentThread;
 SetThreadPriority(ThreadHandle, THREAD_PRIORITY_TIME_CRITICAL);
//===================================================
 try
  AssignFile(F1, 'B:\InstallsTmp\Input.txt');
  Reset(F1);
  AssignFile(F2, 'B:\InstallsTmp\Output.txt');
  Rewrite(F2);  //Blanks file, so no need for FileUtils unit If FileExists stuff... apk
//===================================================
  while not Eof(F1) do
  begin
   Try
    Readln(F1, Ch);
   finally //The "cached commit" makes it slowdown by nearly .5 seconds... apk
    Writeln(F2, '0 ' + Trim(Ch));
   end;
//===================================================
  //EXCESS TRIMS, GOOD 4 CODE & DATA INTEGRITY, SLOWS RUNTIME
//===================================================
  end;
  CloseFile(F2);
  Flush(F2);  //FLUSH OUT OUTPUT FILE BUFFER... apk
  CloseFile(F1);
  Flush(F1);
//===================================================
 except
   CloseFile(F1);
   Flush(F1);
   CloseFile(F2);
   Flush(F2);
   exit;
 end;
 Sleep(1);
end.

====

:)

* IN YOUR CASE? Instead of appending a blocking/leading "0 ", as I am doing above in THIS specific line:

    Writeln(F2, '0 ' + Trim(Ch));


?

Well -  instead, You would append the leading '*.' & any trailing stuff... ala:

    Writeln(F2, '*' + Trim(Ch) + '/*');

NOW, there is actual .INI reading routines mind you, that would do the job even better, & save you time in inserting the output.txt file data into the filter.ini yourself

(Avoiding extra time used, in doing things such as editing the output.txt file, hi-liting & copying ALL of its newly converted data, & pasting into the file to insert it to (in my case? HOSTS) via pasting it there).

You'll probably want to AVOID the "ReWrite" command instruction, because it BLANKS OUT the output file (&, in your case, or the filter.ini file? You do NOT want that, you want to set file access for APPEND, instead - or, just use the recommendation to do the .ini write instead noted above, AND, below).

----

Funny you should ask for this, because, I JUST built that above, yesterday in fact, to do that...

I.E.-> Insert lists of BLOCKING URL's for routers, instead putting it into my HOSTS with a preceeding 0<space> put in front of EACH URL...

So, in the OUTPUT.TXT phase, instead of just outputting your converted data into a separate file?

Just "Directly Inject" it into the filter.ini file itself, via .ini file writing routines (which is QUITE A LOT like registry read/write routines too)... simple!

AND, Delphi's HELP file? Has examples for doing .ini read/write I-O... easy to do as well, trust me.

... keep that in mind!

(I won't do the work FOR YOU, but, instead, I'll give you a fishing pole, & teach you HOW TO FISH YOURSELF, instead... how's that?)

For what YOU want? MOST of what you need, IS basically DONE above... it's just a matter of you altering it (for .ini writes I would say @ most & a diff. line for text line alterations/appends) & compiling + testing it.

----

Technically though (editing now)?  This WILL work!

Using what is above, WITH filter.ini, & your F2 file (filter.ini) set into APPEND mode??

That change will occur, here (vs. the code above):

  AssignFile(F2, 'B:\InstallsTmp\Output.txt');
  Rewrite(F2);  //Blanks file, so no need for FileUtils unit If FileExists stuff... apk

Change YOUR output file, to filter.ini (with pathway to it under C:\Program Files\Opera, for UNIVERSAL access, or by user (underneath your userprofile folders, Application Data subfolder, you will see Opera there too))

& the REWRITE(F2)?? You'll have to set that for APPEND mode access (look that up in Delphi's Object Pascal help, File I/O routines)

& ALSO??? Change your INPUT file from the one I have above:

 AssignFile(F1, 'B:\InstallsTmp\Input.txt');
 Reset(F1);

To HOSTS!

(Inclusive again, of its pathway, typically %WinDir%\system32\drivers\etc)

Additionally, here? YOU HAVE OPTIONS!

You can read the HOSTS file location from Tcp/IP parameters outta the registry IF you wish also, DataBasePathway variable here ->

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters

(via the use of registry READING routines in Delphi/Object Pascal)

OR

Just use routines for determining the %WinDir% (that's in Delphi's HELP files (with examples, too)).

NOW, to get rid of anything in front of the URL's in a HOSTS file, such as 0<space or tab>, 0.0.0.0<space or tab>, or the largest & slowest 127.0.0.1<space or tab>?

Use the STRINGREPLACE instruction (look it up, easy to use)... & voila:


You HAVE A WORKING FILTER.INI writer that inserts HOSTS files entries into FILTER.INI for opera... minus having to keep potentially hijackable javascript code active, & quoting Mr. Stark/Iron Man again?

By maintaining "POWER TO WEIGHT RATIO" (by not using CPU running javascript, & safer too, javascript's the "road to ruin" out here nowadays after all mostly) by doing so & "maintaining fuselage integrity" too (for security via using filter.ini, vs. this .js script you are using), & you get all that, just by not running javascript too! Bonus...

I.E.-> Same working results, @ less cost in terms of CPU usage, & other forms of I/O PLUS safer, @ least potentially by not using javascript.

----

That should work (correction, WILL WORK (editing)), just fine, by piling the newly injected URL's from a list of them, directly into the filter.ini, via appending them (omitting the use of .ini file write really).

----

Heh, I have just about DONE this app, for you... all you have to do, is follow directions, & make the changes noted? It'll work...

APK

P.S.=> I use THAT code above, for:

E.G.-> Reading in a file FULL of lists of sites to block (many folks in security use those, for routers "RULES' TABLES", lists of URL's to blockout from known bad code malware injecting sites, &/or bad adbanners), that only have lines in them, in THIS form:

www.whateverwhereever.com
www.nextwhereever.com

etc. et al...

& I either have the program above APPEND a leading 0<space> to the front of them (for blocking them out & for insertion into a HOSTS file (much faster than doing it yourself over say, 50,000++ entries, & I just did that yesterday using that code above in fact))...

NOW - IF I didn't make this code? Heh - I'd STILL be inserting/editing my HOSTS file, with 50,000 new entries, by hand/manually using notepad.exe, a day later probably (takes TOO long to do this type of thing, manually, & computer are GREAT @ 1 thing: AUTOMATION, & speed of it!)

OR (as I do in another charactermode/tty/DOS 32-bit terminal program like this one)?

I have it "ping" the URL's, & preceed each URL with its TRUE & CORRECT IP ADDRESS... for added speed of URL-to-IP address resolution, by doing so locally via my HOSTS file, instead of wasting time calling out (30ms roundtrip time to DNS server, vs. 0ms using HOSTS file, do the math) to potentially compromised DNS servers... which has happened a LOT recently (see Dan Kaminsky online in fact for this).

It's (the ping model of this program) for doing my FAVORITE SITES appended, albeit NOT with a blocking IP like 0, 0.0.0.0, or 127.0.0.1, but instead with their TRUE & CORRECT IP Address!

(For making fav. sites go faster than they would by calling out to a DNS Server & adding them to a HOSTS file)... apk
Re: project for APK (No, no Senor - PROJECT 4 ASH, instead!)... apk
« Reply #2, on November 20th, 2008, 03:26 PM »Last edited on November 21st, 2008, 08:10 PM by APK
The reason I did that above, Ash? NOT actually, fully, doing the code, FOR YOU, but instead, almost doing so above??

Is so you can say this:

----
YEA... I can FLY!" - Tony Stark/Iron Man
----

(From the film "IRON MAN" & in my fav. scene from it - his first "test flight" w/ prototype version 2.x of his new armor)

I say that, because EVERY TIME I create a new program?

Hey - I get that EXACT feeling (creating something FROM NOTHING, & a something that's useful - this is how Mr. Terrance Howard described that film in fact, he played Rhodes)

LOL, & man... it's a GREAT feeling too! I'd like YOU to feel that way, about this...

(Most of all? Well - AND, you get, exactly what YOU want too, & don't depend on ANYONE to get it - you do it, yourself!)...

Well, after you "debug" out any f-up's you run into ( "run check on control surfaces" - Tony Stark/Iron Man, again, lol!) ... & usually, you do, @ least SOME... ala another fav. scene of mine from said film:

----
"We iced up Jarvis... deploy FLAPS! Jarvis?!? COME ON, We gotta BREAK THE ICE!" - Tony Stark/IRON MAN (from the same body of scenes, my fav. from this fine film)
----

Heh, I ran into THAT, with HOSTS files that are larger than 4mb here, & had to 're-learn' (I forget a LOT of things I knew or know over time in this detailed field/art & science) that when using HOSTS of THAT SIZE?

You need to cut the DNS Client Service - which, mind you, in MS' NT-based OS only JUST recently was discovered & patched (only partial too, mind you)...

DNS Client has had a LONG STANDING & KNOWN "bug" (security vulnerability) in it, that was massively vulnerable via remote takeover, for years... I've been "proofed" vs. that, in that timeframe, via disabling it...

(So, I was lucky... in that I had it set disabled, via services.msc, on its startup type here, for YEARS now - saving memory, CPU cycles, & more on other forms of I/O it performs... bonus! You don't REALLY need it to get online anyhow).

Heh - when I 're-discovered' that?

I felt just like IRON MAN did, while falling to his 'doom'!

Simply because I almost put that out online without telling others about it!

(& I have had myself set that way, minus DNS Client service, for YEARS now, because of HOSTS files usage for added speed, & SECURITY, online)

Yes - I laughed my butt off, just as IRON MAN/TONY STARK did too, when he recovers from that (as I did on HOSTS & DNS Client)...

:)

----

BOTTOM-LINE:

* See... IF I do the work for this, for you?

You don't learn a thing...

I.E.-> YOU, personally, don't get STRONGER!

This way @ least, though I did MOST of what you need above, & imo @ least? You can get this done, &? Far MORE EFFICIENTLY!

(Simply by using FILTER.INI rather than user.js (avoiding using javascript totally which costs CPU cycles, RAM, & other forms of I/O too + for security reasons (avoid javascript is all I can say))

APK

P.S.=> I feel, personally, that you're (yes YOU personally) are on the "verge" of making/taking that "next step" in your "computer nerd evolution"... & that?

That's CODING Ash... & sometimes?

----
"Jarvis? Sometimes, you gotta RUN... before you can walk!" - Tony Stark/IRON MAN (again, from the film IRON MAN, same scene)
----

... &, by using FILTER.INI, rather than this .js file? We also "maintain power-to-weight ratio & insure fuselage integrity" - Tony Stark/IRON MAN, by the avoidance of javascript usage, altogether (bonus for speed, AND security).

apk
"There must be security for all, or no one is secure. NOW - This does not mean giving up any freedom, except the freedom to act irresponsibly. We do not pretend to have achieved perfection, but we do have a system - and it works. Your choice is simple:  Join us, & live in peace... or pursue your present course, & face obliteration. We shall be waiting for your answer (The decision rests with you)..." - Klaatu, "The Day the Earth Stood Still"