Backdoor yourself for fun and ???

Software you wrote

Backdoor yourself for fun and ???

Postby Doug Coulter » Mon May 06, 2019 10:12 am

I recently had a serious attack of "crazy old coot" and decided to have a little fun. As many will know, I have a number of small computers around, things like raspberry pies - to help automate the place, watch the road (it's otherwise a long walk to see if the mail is here), the garden, control some things (water system) and so on. Though an engineer, wiring is about my least favorite thing to do - especially hard-wires between computers that have to be outdoors, it's getting crazy here already, stuff that sees much sun goes bad (even a tiny failure rate is bad when the amount of stuff is large), and "spread out, computers, one lightning strike will get you all".

So the situation was this - I have a camera watching my garden (someone nicely came unasked and tilled it, so what's a guy to do? Plant stuff!).
There is also a passive IR long range detector there that radios to my living quarters (a whole building away and a long walk to the garden). It false alarms a lot.
I have an electric fence charger that will put the fear of death into any being - but thick enough fur and it won't jump through, and deer, well, anyone who does a garden knows that unless you put a cage over the entire thing, they're just going to jump over anyway. It's a puny effort this year but this is for the fun of it anyway.
gardcam.jpg
View of the garden, the IR detector is on that post at the far end. The computer controlling scary lights and sound is on the other end of the building.,


So, now for the fun part - totally impractical, except that it seems to work and is entertaining on top.
For the pi that's most proximate to things, I added an interface to turn some AC power on and off, and that power runs two super bright LED floodlights - they hurt to even glance at in daytime. This power also runs a class D 50w/channel audio amplifier, connected to a pair of outdoor horn speakers mounted on the side of the building, and all this is pointed at the garden... perhaps you can guess where this is going.

So, I get a bing-bong from the alarm. I spin up the monitor camera website, but it's dark. That camera is outside, runing on wifi and on its own long power lead in a porch so as to get the "long view" of the garden. It's not reasonable to hook it up to the "scare the intestinal content out of varmints" hardware. So, while I could easily have come up with some more secure proprietary way of doing this...I found this more generally useful in cases where you don't care one whit about security and don't want to have to overly customize this for each different use. You could actually add a little whitelist so it's not open to everyone, but hey, I'm on non routable IPs out here in nowhere - if you're in range of my wifi, you're in easy range for a rifle...and all my neighbors are friends.

So, what did I do? If you know the secret UDP port on the secret IP address of your target running this code, you can just send it bash commands and it'll do them.
Like telnet, only no login required - this is REALLY BAD SECURITY so don't blame me if you hold it wrong.

I simply created a daemon in perl, with a .service file for the new kidz systemd bullcrap, and it sits there waiting for a message on a port known to it (and now, you know too - it's UDP 42666) - you can choose your poison from any high number port not already in use. This daemon will pass whatever you send it to bash via perl's system() command...

And sending that command is as easy as this:

$echo "whatever I want" > /dev/udp/hostname/port (or any other way of sending a UDP packet to a known place with known content)

That is, if you're running my tellem/tellme pair so hostnames and IPs are in the /etc/hosts file. If not, you have to use an IP (dotted quad) instead of hostname,
You're not going to hang if the thing isn't there....

This way, I don't have to flip web pages and push a button on one to get something to happen on the other machine....
There are probably thousands of other ways to get this done, but since I had that daemon and systemd thing hammered, it was a minor mod to existing stuff.
In this case, I'm remotely calling "macros" in Raspberry_Pi_Cam_Web_Interface from a remote machine, ones defined with the userbuttons file. More here:
https://elinux.org/RPi-Cam-Web-Interface
There's quite a bit going on in that code. If I knew how to make obfuscated javascript mixed into php send an onclick message to itself....oh well.

So here's an example of some "not too dangerous" code that only prints out what you sent it if you start it from a command line. Change the one print line and turn off $debug (set it to 0) and you have your backdoor:
You'll need modules "Modern::Perl" and POSIX to run this. You can substitute use warnings; and use strict; for Modern::Perl or just comment that out.
I think the rest is in the perl core anyway.

Code: Select all
#! /usr/bin/perl
use Modern::Perl; # kinda the same as use warnings and strict, and enable some new stuff
use IO::Socket; # so we can hear
use POSIX; # big honkin module, but we need some of it

#daemon

# *********** globals
my $time_to_die = 0; # shutdown cleanly
my $pid; # for daemonizing
my $debug = 1; # turns printing and daemonizing on and off
my $msgsock; # the socket
my ($rin,$rout,$rgood); # vectors for select func
my $portno = 42666; # commmand port
my $maxtoread = 1024; # arbitrary max length
my $them; # their IP from recv?
my $msg;  # the incoming message
#****************************************
sub signal_handler
{ # so we die gracefully when told to
$time_to_die = 1;
}
#************** main
unless ($debug)
{             # daemonize self
setpgrp(0,0); # try to be as rooty as we can be
$pid = fork(); # we're going to detach from whoever started us
exit if $pid; # parent dies
die "Couldn't fork: $!" unless defined($pid);
POSIX::setsid() or die "Can't start new session: $!";
close (STDIN); # never use it anyway
close (STDOUT) unless $debug;
close (STDERR) unless $debug;
$SIG{INT} = $SIG{TERM} = $SIG{HUP} = \&signal_handler;
}
# get a port we'll listen on
$msgsock = IO::Socket::INET->new(LocalPort => $portno, Proto => "udp")
                           or die ("couldn't bind to port:$!");
$rin = '';
vec ($rin, fileno($msgsock),1) = 1;

print ("waiting for message\n") if $debug;

########################################## the main loop ##############3
until ($time_to_die)
{
$them = select($rout=$rin,undef,undef,10);
if ($them) # we have a message
{
  $them = $msgsock->recv($msg,$maxtoread);
  print ("\nmessage received:$msg\n") if $debug;
# put in some more interesting call like system($msg); here to get your backdoor

} # you could put an else here if there's other work to do
}
__END__



And here's the .service file, which should be put somewhere like /etc/systemd/system. Make it owned by root, not world write-able or executable. Then you say
Code: Select all
[Unit]
Description=run bash command from udp port, horrible backdoor
After=network.target

[Install]
WantedBy=multi-user.target

[Service]
Type=forking
Restart=always
ExecStart=/usr/bin/UDPspawnd
IgnoreSIGPIPE=false


$sudo systemctl enable UDPspawnd
$sudo systemctl start UDPspawnd

At the target end, I've installed sox (along with the mp3 library for it) because I like that swiss army knife for audio. You can then do things like:
$play -q /any/path/I/want/*.mp3 gain -3
for just one example of a use.
Experienced linux users will know to put an & after the command to get the terminal back before the play is done.

I went here: https://www.freesoundeffects.com/free-s ... ror-10085/
To get some interesting sounds to put together in Audacity for repelling the critters.

I'm hoping to get a good enough frame rate under those lights to get some footage of "varmint running for its life". At any rate, it beats suiting up, going and out and shooting them.

This isn't really an exploit any more than onanism is rape...(did I say that out loud? :oops: But do wash your hands. ).
Posting as just me, not as the forum owner. Everything I say is "in my opinion" and YMMV -- which should go for everyone without saying.
User avatar
Doug Coulter
 
Posts: 3515
Joined: Wed Jul 14, 2010 7:05 pm
Location: Floyd county, VA, USA

Re: Backdoor yourself for fun and ???

Postby Bob Reite » Tue May 07, 2019 3:07 pm

So what sound effects will you use to scare the critters? I had a black bear looking over the chicken coop the other day and I yelled at him "Don't even think about a chicken dinner bear, or I will have bear meat dinner!"
He took of a running and I never saw him again.
The more reactive the materials, the more spectacular the failures.
The testing isn't over until the prototype is destroyed.
User avatar
Bob Reite
 
Posts: 142
Joined: Wed Nov 11, 2015 1:02 pm
Location: Wilkes Barre / Scranton PA

Re: Backdoor yourself for fun and ???

Postby Doug Coulter » Wed May 08, 2019 9:55 am

Right now, I'm using a track I put together(using Audacity) with coyote sounds from the source above. I made it so that in the stereo image, they're coming towards you (the varmint) and getting more agitated, till a bobcat shows up and snarls and they all run off together. So far, none of the plant-earthers, um, herbivores have lasted all the the way through the short clip. (I thought I'd typed eaters there, but hey, you take free humor where you find it)
BTW, the pyle drivers are 100db 1w/1m and I have 50w apiece on them. It's earsplitting when the one coyote clip starts yipping. Dynamic range 'r us.

I need to remember to start recording and figure out some way to up the frame rate a bit - it's kind of slow on the night setting, so I'm not getting good recordings yet. I get about 3-4 frames of a small furry brown thing running away as fast as it can. 100% success by that measure - no damage to the garden so far.

I've had bears here too - the cat food dish (no longer out there, I'm catless right now) brought in all kinds of critters, one even curling up on my porch as if asking to be adopted. Yelling worked at first but they got bolder, and mama even stood up against my front door and it pushed open, leaving her and me, both very shocked, in my living room. Shooting nearby (not to hit, but to scare) worked, but really the thing was getting rid of all the free food. I did wind up shooting one possum and one racoon who just wouldn't respond to the usual chasing away with a broom. But that leaves you a mess to clean up. And any "real" gun (eg not the .22 LR rifle by the door) needs hearing protection - I value my ears.

cub1.png
Cute despite bad photography through the door - mama at 500+ lbs and ~7' was in the shadows outside the field of view. The cub is cute - but things that could kill me by accident do put me off a bit.


I'm not sure what would scare bears. My earlier visitors didn't mind a 1kw halogen light and after awhile, being yelled at either.
I did wire up some alternating strips of metal window screen on a sheet of HDPE and connect it to the output of a 15kv 60ma neon sign transformer so it was really difficult to not be across the thing. But I only got possums with it, not very entertaining other than the one who made contact with their nose - the smoke was quite a picture. By then, the bears had chosen other scavenging grounds. I'm not sure even my semi-auto AR10 in .308 would do it fast enough at close quarters with something that huge...(lesser rounds have been known to bounce off bear skulls). I got it out and ready anyway - and like that elephant-repelling rock, it worked, I never saw them again.
Posting as just me, not as the forum owner. Everything I say is "in my opinion" and YMMV -- which should go for everyone without saying.
User avatar
Doug Coulter
 
Posts: 3515
Joined: Wed Jul 14, 2010 7:05 pm
Location: Floyd county, VA, USA

Re: Backdoor yourself for fun and ???

Postby Doug Coulter » Wed May 08, 2019 10:12 am

Here's an early example clip - I set the code up to just play all the mp3s in a directory when triggered. This is one of them.

Also so as not to leave my backdoor utterly swinging in the breeze, here I allow only a couple of particular things to work remotely by adding this rather than the print statement in the example:

Code: Select all
chomp $msg;  # get rid of any trailing newline
if ($msg =~/^\/var\/www\/html\/macros\/button\d.sh( &)?$/)
{ # matches button#.sh at the right path with or without a trailing space and &, else we ignore it.
  system($msg);
}


Of course, the regular expression that looks crazy in the above if statement is one reason people say they can't read perl - even though
every serious language now boasts "perl compatible regular expressions" or PCRE....
And yes, they make my head hurt too, I only use them when I must, rather than as a job-security easter egg. When they do something cool and easy, they're worth it.

The initial ^ means the match has to start right at the start of line. The $ at the end means it has to end at the end of the line (these are called anchors).
The funny \/ junk is a way to say / without confusing the parser - since / is also a special character itself in regexes. the \d means "one numeric digit", and the ? means "0 or one of whatever atom came before", in this case I used ( &), a space followed by an ampersand, since one of the things I want to tell it to do takes a long time, and I don't want it to wait for the play to finish before it gets around to turning on the lights...just spawn play /some/path/*.mp3 is one of the things this invokes.

At any rate, this RE leaves very little room to pass anything but "buttonN.sh &" to the shell on the remote machine. You can leave out the ampersand, and use any single digit after button and before .sh (but I only implement 2 of them - bash will ignore the rest). So, not perfect security, but this is inside my lan, and scanning based on IP wouldn't mean much (it's all gonna be 192.168.1.xxx anyway).
Attachments
GardenCoyotes.mp3.tar.gz
Some lo fi noises - good enough to work
(510.12 KiB) Downloaded 338 times
Posting as just me, not as the forum owner. Everything I say is "in my opinion" and YMMV -- which should go for everyone without saying.
User avatar
Doug Coulter
 
Posts: 3515
Joined: Wed Jul 14, 2010 7:05 pm
Location: Floyd county, VA, USA

Re: Backdoor yourself for fun and ???

Postby Bob Reite » Wed May 08, 2019 6:10 pm

You do NOT want to get between that sow and her cub! I guess all black bears around here figure that humans all carry boomsticks and don't want to stick around to chance getting shot at. Except for the chicken coop, I make sure there is nothing left outside that bears would think is food. Oh. That time a couple of years ago that a mountain lion was spotted, I started carrying the Webley Mk VI Revolver when I was outside. It is one of many with the cylinder faced milled so as to take .45 ACP with moon clips, or .45 Auto Rim cartridges. That should also suffice should it be a life and death issue with a black bear.
The more reactive the materials, the more spectacular the failures.
The testing isn't over until the prototype is destroyed.
User avatar
Bob Reite
 
Posts: 142
Joined: Wed Nov 11, 2015 1:02 pm
Location: Wilkes Barre / Scranton PA

Re: Backdoor yourself for fun and ???

Postby Doug Coulter » Wed May 08, 2019 7:20 pm

A no-kidding Webley! Now you're making me jealous. Not sure even a .45 ACP hardball would do bear skull (my FN 5-7 would penetrate, but it's otherwise just a 35 gr ti ap bullet), and if you hit other places, well, you can die waiting for the results...that's the thing, a fairly small moving target that's the only one that kills quickly (you need a CNS shot) with something the size of a compact car that may not be showing you that shot as it comes for ya - from one length away. I knew better than to get in the middle of that one...I don't think Mom hates me (yet), but I know that's poison. That's why I took that picture (it's a frame capture from my video cam) from indoors - and didn't even open the dirty glass door, mom was just behind the cub, in the dark - visible to the eye but not the camera.

They have a really decent sense of smell - they could have smelled something inside your coop. Or not, they're often just very inquisitive scavengers looking for anything at all that might be food. This same group of black bears hit on a neighbor who was keeping a 50 gal or so metal trash can of bird seed near his bird feeder, strapped and locked up. They tore that apart like confetti and gorged on it while he took pictures.
(He has an amazing gun collection and we shoot together when we have time - I do custom loads for the neighbors. I don't think he has a Webley though - )

Neither of us want to shoot something like that (and we've both been warned by Fisheries and Game dept not to). They're supposedly trying to re introduce them around here, and use "the battery in the collar went dead" as an excuse to do their main helicopter mission - find the guys growing pot.
I didn't see a collar, but that's their story and they're sticking to it.

I'm a dead shot with my CZ-97B in .45 ACP (10+1) but I dunno if I'd want to face down something that large, I'm not that super brave. The rifle from behind cover sounds nasty enough (even .308 with 20 round mag), but what then? I don't have a front end loader to remove the evidence. Anyway, as long as they don't eat me, they're cute.

But after around 3 visits and me shouting them off and waving a stick (not a gun, just a stick) - they stopped scaring off so easily, which is why I wired up that electric porch, but as far as I know, I just converted one big possum to an imitation dragon (snout smoked and flamed quite satisfyingly - a jacob's ladder to the nose is a thing of beauty in this case). I only plugged that in when I saw something out the window after the little motion sensing radar beeped (those cheap modules on aliexpress etc - they really work well at short ranges). No point in injuring a neighbor's pet that just dropped by or myself if I forget it's on.

I didn't even wire up the electric fence this year - even though it's one joule per pulse and will start fires with weeds...it's not high enough voltage to breach thick fur, and deer around here can jump over almost anything anyway. The EMI from that thing messes up all my scope traces on the whole campus too.

Edit - Giggle, just after I hit submit the alarm beeped and I was treated to the first deer of the season - seems the groundhogs and racoons found it first this year.
And it works 100%. I gotta get in the habit of hitting the record button before the "scare them" button....things happen really fast.

####
I should be running with big RF again soon - I just need sunny weather and a minor repair to the interstage coupling transformer in the RF amp (Seems to be a break in the glass tape where it intermittently arcs from plate volts of the 6146 to the grid of the 4-125s winding - but damn those tubes are tough.).

If you have a way to listen around 2.645 mhz....that's around where I am right now. Enough radiates that a 2w neon bulb lights brightly at 3 feet away from it - just supported on an insulating stick, no "antenna". I guess I should fire up a good receiver and see if anyone else is using that...

///
I'm going for the "other" mode next, where I make ions another way and just push a few around with the RF. What I think I've figured out is that if you excite it hard enough with this thing with enough gas so there's a short mean free path (1-2 inches), you just made a lightbulb that isn't very efficient. I can't drive that to "interesting" voltages, it's like a turned on thyratron (And would take 10's of microseconds or more to deionize - maybe a lot more than a real thyratron as even when my pressure is high for me, it's low for a power thyratron). Halve the pressure to where that doesn't happen - say 6" mean free path, and I can make 10's of kv of RF and add in DC to that. That's next. In that case, my resonance is a little bit lower - the ions are acting like a few pf cap at least at the settings I've tried. And I do get more neutrons but haven't gotten the other data I want like velocities and bunching vs the rest of the parameters. Not even sure I'm in the right octave yet but it seems like more than one thing can work or at least more than one thing produces some interesting effect which may not be the same at LF vs RF. Last time I got these weird velocity measurements that were well under C for any particle we know of, but way too fast for the voltages (for example if it was electrons, they were moving at 133 keV - sanity check fails), so I'm assuming we're seeing some oddball thing like dielectric polarization with it's own weird prop time as it ripples through the media.
Posting as just me, not as the forum owner. Everything I say is "in my opinion" and YMMV -- which should go for everyone without saying.
User avatar
Doug Coulter
 
Posts: 3515
Joined: Wed Jul 14, 2010 7:05 pm
Location: Floyd county, VA, USA

Re: Backdoor yourself for fun and ???

Postby Bob Reite » Sat May 11, 2019 10:54 pm

Lost one of my free range chickens, probably to a bobcat. She was the stupid one that would wander off by herself rather than sticking with the rest of the flock. Now that I'm down to just three birds I'm going to keep them cooped up, they do have a run that's big enough for three full size hens

Back to the world of fusion.

Really too bad we never got to look at your "Gonzo mode" device (the one that had to be parasitic oscillations) with a spectrum analyzer. Then we would know what to shoot for frequency wise.
The more reactive the materials, the more spectacular the failures.
The testing isn't over until the prototype is destroyed.
User avatar
Bob Reite
 
Posts: 142
Joined: Wed Nov 11, 2015 1:02 pm
Location: Wilkes Barre / Scranton PA

Re: Backdoor yourself for fun and ???

Postby Doug Coulter » Sun May 12, 2019 7:20 am

Yes, that's been insanely frustrating - the main way I knew I was having something very strange going on unfortunately was that all my data aq more or less crashed or in a couple cases, actually burned.

I'm happy to tell what I know...or think I know.
I had a medium Q inductor in series with the supply - I still have it and one or two others that produced results much more interesting than the usual ballast R (which I'd stopped using once I got rid of all feedthrough arc issues anyway). The measured resonance with no gas/ions tended to be in the 1.6 to 2.2 mhz range for some, but the "magic" one was much more inductance but lousy electrical Q, pictured below. (having a coil winding jig built for your lathe and tons of wire will encourage one to try stuff!)

I was running my full 50kv or very nearly, running an ion source (same one I'm using now - just a reduced size grid out in the big tank with DC on it - current limited to 2.5 ma and usually in the 10-20kv range) and running system gas pressure on the hairy edge of what would work under Paschen's law - and in fact in "the event" I had what seemed to be some kind of relaxation oscillation going on - huge kick back from the inductor re-accelerating a few ions might explain some things? But the (electrical) Q wasn't that great, even unloaded! Don't know, the numbers were "too fantastic" by normal fusor standards, though when thought about, still way not over unity either...just enough to be an issue to be in the room with. I've since re-instrumented with stuff that won't fry or blank from high count rates, and been slogging away trying to get this going as a driven thing....rather than as a lucky chance. hopefully I don't obsess too much and go alcoholic like that other Philo guy...

I've kind of tried to look at what it could possibly have been - and still fit within the standard model (with only explains after the fact, it's a terrible predictor).
And slowly working through the numerous possibilities. And that's about all I know so far, it's frustrating. And in some sense a risk. But giving up is a sure-thing loss.

This oddball run - I didn't even have the main DC on, it didn't blank the detectors (you can sure hear them), there's no proof some of what I measured wasn't RF noise, but it sure doesn't sound like it on the speakers! Is one example, one of the more significant events. For ref, 980 cpm on the hornyak is 1 million neutrons/second as calibrated via multiple tests with consensus at Richard Hulls place on a run of his. I usually just use 1k/million to be both conservative and easier on my head.
https://youtu.be/7JVfR6wZ1pU


Here's one of the few informative ones on either the gonzo mode or something close. I didn't mention that even though we were breaking a million n/s, that the actual duty cycle was a lot less than 100% for these conditions....
https://youtu.be/KjsSoTdpHxM


Here's the inductor. Several I built gave very roughly similar results, but this one hit it on the head. All resonated with the grid/ft somewhere. This one, at around 5 mh, should have been resonant at around 250khz. Another one that gave really good but not as spectacular results (in what looked like stable running) resonated at 1.8 mhz. I tried a couple in that range of varying (electrical) Q but never went anywhere much with that. They helped some compared to nothing.
20190512-Fusor inductor-1.jpg
The inductor in the main feed. I might have had a chunk of ferrite in there, but probably not.


I did have a 50 or 100k ww 200w resistor in series with the ion grid DC. Those aren't "flat" but they don't have much Q either. Often (I guess I should go measure) they act more like C than L or R at fairly high frequencies. Just in case that matters, and at this point, I don't have a clue what really matters here.

Tried again..
Got about the same results. And some change I don't remember making and it's gone...maybe a shorted turn on that inductor or any of a super long list of "maybe".
But darnit, I was there, I know what I saw and measured (and couldn't measure because something - RFI - was so loud - a hint itself) - that this wasn't imaginary)

This is maybe the wrong thread for this - but that's not all bad. The "right people" who are following along in general are who this kind of raw data are intended for anyway. Some kind of "security by obscurity" is in effect here.
Posting as just me, not as the forum owner. Everything I say is "in my opinion" and YMMV -- which should go for everyone without saying.
User avatar
Doug Coulter
 
Posts: 3515
Joined: Wed Jul 14, 2010 7:05 pm
Location: Floyd county, VA, USA

Re: Backdoor yourself for fun and ???

Postby Doug Coulter » Sun May 12, 2019 3:40 pm

I started a new thread for this, here: viewtopic.php?f=21&t=1131&p=6672#p6671
Better place to put all the info together for figuring this out. Help very appreciated!
Posting as just me, not as the forum owner. Everything I say is "in my opinion" and YMMV -- which should go for everyone without saying.
User avatar
Doug Coulter
 
Posts: 3515
Joined: Wed Jul 14, 2010 7:05 pm
Location: Floyd county, VA, USA

Re: Backdoor yourself for fun and ???

Postby Bob Reite » Sun May 12, 2019 6:07 pm

I'm going to have to grab my 200W 100K wire wound resistor and see what frequency it's self resonant at.
The more reactive the materials, the more spectacular the failures.
The testing isn't over until the prototype is destroyed.
User avatar
Bob Reite
 
Posts: 142
Joined: Wed Nov 11, 2015 1:02 pm
Location: Wilkes Barre / Scranton PA

Next

Return to Homebrew

Who is online

Users browsing this forum: No registered users and 4 guests