pixelserv without perl, without any jffs/cifs/usb free

Post new topic   Reply to topic    DD-WRT Forum Index -> Broadcom SoC based Hardware
Author Message
redhat27
DD-WRT Novice


Joined: 20 Jan 2010
Posts: 41

PostPosted: Sat Apr 24, 2010 2:08    Post subject: pixelserv without perl, without any jffs/cifs/usb free Reply with quote
Hi everyone...

Just wanted to share this info: If you are in my condition and use a dd-wrt mega build on a 8MB flash router without mmc mods or usb attached, you realized after enabling jffs, you have no space free to store stuff. Thats bad news if you want to run pixelserv on your router for adblocking, as that needs perl (optware install which you do not have the luxury of). Well don't fret: you can still create pixelserv binary on the fly and run it from a start script.

I did not create the ELF binary: I got this from the linksysinfo forum the source provided by mstombs

Okay, so here goes:

First, you need atleast 4k of nvram free (normally the router has 32k nvram to store variables)

Check with:
Code:

nvram show | grep ^size:


If you can spare 4k (keep atleast 1k cushion for other router functions like dhcp leases, etc)

Paste the lines from the atached custom.txt file your Administration->Commands->Save Custom area

If you already have a custom script, append the contents at the end: just make sure to take out any exit commands if there were any existing, and also the first line in the attached custom.txt file (#!/bin/sh)

Then in your startup, invoke the custom.sh:

Code:

while [ ! -e "/tmp/custom.sh" ]; do
  sleep 1 # wait till /tmp/custom.sh gets generated
done
/tmp/custom.sh
logger "Redirecting httpd to port 81"
killall httpd
httpd -p 81 -h /www
logger "Starting pixelserv on port 80"
/tmp/pixelserv `nvram get lan_ipaddr` -p 80


If that was not obvious, it moves the httpd on your router to listen on port 81, so you'd still able to get to it with http://<router_ip>:81

Now you can run ad-blocking on your router (blocks ads from all computers in you lan, no need for Firefox/IE/Chrome plugins on each PC)

You can find several forum threads on how to do hosts based adblocking by downloading (wget) the hosts.txt from mvps.org and instructing dnsmasq to use the downloaded hosts in addition to your own hosts file. pixelserv will serve a 1x1 pixel transparent gif picture for your blocked ads.

Enjoy!



custom.txt
 Description:
Open with any text editor and copy/paste the contents to the commands box, then [Save custom script]

Download
 Filename:  custom.txt
 Filesize:  3.64 KB
 Downloaded:  2172 Time(s)



Last edited by redhat27 on Thu Apr 29, 2010 1:38; edited 1 time in total
Sponsor
autobot
DD-WRT Guru


Joined: 07 May 2009
Posts: 1596

PostPosted: Sat Apr 24, 2010 4:23    Post subject: Reply with quote
Thanks for your informative post, frater had this done a while back.
_________________
Eko Builds

BrainSlayer Builds

DD-WRT Changelog RSS Feed
crashfly
DD-WRT Guru


Joined: 24 Feb 2009
Posts: 2026
Location: Sol System > Earth > USA > Arkansas

PostPosted: Sat Apr 24, 2010 6:25    Post subject: Reply with quote
Still a good post though autobot. It is nice to see some people thinking outside of the box even though it has been accomplished before.
_________________
E3000 22200M KongVPN K26
WRT600n v1.1 refirb mega 18767 BS K24 NEWD2 [not used]
WRT54G v2 16214 BS K24 [access point]

Try Dropbox for syncing files - get 2.5gb online for free by signing up.

Read! Peacock thread
*PLEASE* upgrade PAST v24SP1 or no support.
autobot
DD-WRT Guru


Joined: 07 May 2009
Posts: 1596

PostPosted: Sat Apr 24, 2010 6:28    Post subject: Reply with quote
crashfly wrote:
Still a good post though autobot. It is nice to see some people thinking outside of the box even though it has been accomplished before.


I thanked the OP fRolling Eyesr the post.

_________________
Eko Builds

BrainSlayer Builds

DD-WRT Changelog RSS Feed
crashfly
DD-WRT Guru


Joined: 24 Feb 2009
Posts: 2026
Location: Sol System > Earth > USA > Arkansas

PostPosted: Sat Apr 24, 2010 6:31    Post subject: Reply with quote
Yeah, I saw that. I suppose it sounds as if I was being an ass. My apologizes.

Still a good post though. Very Happy

_________________
E3000 22200M KongVPN K26
WRT600n v1.1 refirb mega 18767 BS K24 NEWD2 [not used]
WRT54G v2 16214 BS K24 [access point]

Try Dropbox for syncing files - get 2.5gb online for free by signing up.

Read! Peacock thread
*PLEASE* upgrade PAST v24SP1 or no support.
autobot
DD-WRT Guru


Joined: 07 May 2009
Posts: 1596

PostPosted: Sat Apr 24, 2010 6:33    Post subject: Reply with quote
No worries crashfly, we all have those days...you know I do lol Smile
_________________
Eko Builds

BrainSlayer Builds

DD-WRT Changelog RSS Feed
mstombs
DD-WRT User


Joined: 31 Oct 2007
Posts: 151

PostPosted: Sat Apr 24, 2010 9:48    Post subject: Reply with quote
Fantastic use of nvram and uucode gz! I must try on flash challenged wrt54gs5. I wonder why the ELF binary compresses so much, maybe there's more that can be stripped?

There's a dd-wrt thread with a version compiled using the dd-wrt toolchain here:-

http://www.dd-wrt.com/phpBB2/viewtopic.php?p=347299

A version compiled with inetd support is included in Frater's optware package tools

http://www.dd-wrt.com/phpBB2/viewtopic.php?t=59668
http://www.dd-wrt.com/wiki/index.php/Optware,_the_Right_Way

There's been a patch to tomato httpd code to stop it binding to all IP addresses on port 80, which allows pixelserv to be be bound to a secondary IP address without moving the router GUI port, not sure if this can be incorporated in dd-wrt.

The pixelserv.c c-code is intended to be portable, I also test on latest Ubuntu 32 and 64bit, and XP with cygwin.

It appears that the router pixelserv binary is fairly router OS independent and the same binary works in both K24 and K26 builds - the library calls and links must be the same. But different toolchains do not produce binary identical images, and you are recommended to use the correct one for your firmware. The latest Tomato version uses a K26 tomato gcc 4.x toolchain published in git by user teddy_bear, it is based on OpenWRT build tools, and probably closer to Tornado's K26 dd-wrt toolchain than older Linksys/Tomato gcc 3.x version.
redhat27
DD-WRT Novice


Joined: 20 Jan 2010
Posts: 41

PostPosted: Sun Apr 25, 2010 17:28    Post subject: Reply with quote
Thanks everyone for the kind words. And wow: My post evoked a response from mstombs himself... I am humbled :)

I had to put it in nvram as I had no other storage options available, and also I did not find a place from where I can wget it every time at router boot.
gendouhydeist
DD-WRT Novice


Joined: 28 Nov 2010
Posts: 3

PostPosted: Sun Mar 04, 2012 23:47    Post subject: Reply with quote
does this work on ralink devices?
mstombs
DD-WRT User


Joined: 31 Oct 2007
Posts: 151

PostPosted: Mon Mar 05, 2012 21:15    Post subject: Reply with quote
Do you mean nvram, optware or the c pixelserv binary? The latter likely to need to be recompiled with correct toolchain as was done for Atheros routers. There is some possibility of binaries from one router working on another - I have seen some mipsel binaries that work on both Ti AR7 ADSL routers and Broadcom Ethernet routers - things are clearly similar at the mips Linux uclibc level. But some Tomato binaries don't work from one version to another!
FrancYescO
DD-WRT Novice


Joined: 22 Oct 2013
Posts: 30

PostPosted: Mon Mar 30, 2015 23:35    Post subject: Reply with quote
Code:
/tmp/custom.sh: line 6: uudecode: not found

Sad
mstombs
DD-WRT User


Joined: 31 Oct 2007
Posts: 151

PostPosted: Tue Mar 31, 2015 18:33    Post subject: Reply with quote
Do you really want to try to use this old version of pixelserv from nvram on a current router?

The c-code functionality has been developed further over the years and recently taken on by HunterZ

https://github.com/HunterZ/pixelserv

There are binaries for Tomato mips on github, and arm in the linksysinfo thread. Not tested recently on dd-wrt, would be best to use the correct firmware toolchain.
FrancYescO
DD-WRT Novice


Joined: 22 Oct 2013
Posts: 30

PostPosted: Wed Apr 01, 2015 21:30    Post subject: Reply with quote
mstombs wrote:
Do you really want to try to use this old version of pixelserv from nvram on a current router?

The c-code functionality has been developed further over the years and recently taken on by HunterZ

https://github.com/HunterZ/pixelserv

There are binaries for Tomato mips on github, and arm in the linksysinfo thread. Not tested recently on dd-wrt, would be best to use the correct firmware toolchain.

i was just interested to the "extract binary from nvram function" ... seems i cannot use jffs2 on my router (wdr3600 is also an atheros..) and i don't want to attach an usb drive
mstombs
DD-WRT User


Joined: 31 Oct 2007
Posts: 151

PostPosted: Thu Apr 02, 2015 17:24    Post subject: Reply with quote
I've seen a trick using openssl to do the equivalent of uudecode, not sure if your openssl will have that function...


Block DHCP over bridged VPN
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> Broadcom SoC based Hardware All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum