P2P In 15 Lines of Code
nile_list writes "Edward Felten of the very fine Freedom to Tinker has written a 15 line P2P program in Python. From the post on Freedom to Tinker, "I wrote TinyP2P to illustrate the difficulty of regulating peer-to-peer applications. Peer-to-peer apps can be very simple, and any moderately skilled programmer can write one, so attempts to ban their creation would be fruitless." Matthew Scala, a reader of Freedom to Tinker, has responded with the 9 line MoleSter, written in Perl."
Freedom to Tinker has written a 15 line P2P program in Python
Does anyone have a
Trolling is a art,
15 Lines? 9 Lines.
The python code has
import sys, os, SimpleXMLRPCServer, xmlrpclib, re, hmac
The perl code puts multiple commands in one line.
Those are both cheating. And not really 15 or 9 lines of code. How many lines of code are just os.py alone? Using these upper level languages is not a good way to prove how simple these activates are because they use many complicated libraries preinstalled in the language. It is like saying I can write a webserver in 3 lines of code.
#!/UpperlevelProgrammingLanguage
Import webserver
Run Webserver
Version in lower level language like C with just say the <includes> are better but still a bit of cheating. If you did in in assembly then that is even fairer. The true test is how many lines of code in assembly without an OS.
If something is so important that you feel the need to post it on the internet... It probably isn't that important.
Anyone can write a P2P client, but who will you network with? Not very useful with the other P.
if whitespace didn't mean something.
Do Perl developers have some kind of reverse size-compensation complex?
Anything you can do I can do smaller?
in one line of code? I have seen object oriented versions of hello world... http://laguna.fmedic.unam.mx/~daniel/pygtutorial/p ygtutorial/x101.html
Is this a first post?
just a web application developer and instructor in Toronto, ON Canada
P2P Does Not Break the Law
People Do
http://www.xanga.com/home.aspx?user=nickrackley/
...but it only worked with 1 dimension. I'm working on scaling it up, but I'm worried it might get longer.
*Someone* had to respond with a Perl script. I guess the animosity hasn't yet subsided.
I can see P2P becoming the next DeCSS in the eyes of the courts and receiving similar treatment.
So when can I expect my shirt?
I'm Matthew Skala, the author of MoleSter, and my name was spelled correctly in the item I submitted about this.
I have just created a zero line P2P program which I have entitled "Walking to the Neighbor's House to Borrow a Movie".
I could be evil and patent it, but I have decided to release it under the GPL.
I'm waiting for the mod chip for my game console.
"Can there be a Klein bottle that is an efficient and effective beer pitcher?"
...are dedicated to spyware if its anything like kazaa.
Well I can write "Pointless story" in one line.
Thinkin' Lincoln - a web comic of presidential proportions
umm.. methinks, not the best name for it
Sure beats Shawn Fanning's code quality and its cross platform!
From the webpage: Every time I look at the word "molester" my brain tries to parse it as "mole-ster" instead of the agentive of "to molest", and now I have an excuse to name a piece of software MoleSter, so I'm going to use it.
I think that the RIAA and MPAA are going to get a lot of positive spin when people start reading that they're going after all the MoleSters on the Internets.
"What do you think?" "I think 'What, do you think?!'"
I have just DESTROYED a MINUS TEN line P2P program!
or did you mean Scalia?
I think I'll stop here.
Go away, stupid troll. Take your anti-Chinese rantings elsewhere. We're sick of them and we don't care.
#!/bin/bash
### ToDo: Write P2P app here
Molestation and child abuse are hee-larious. Keep sending out the laughs, mr funny computer nerd.
But according to this article from a story that was posted on Slashdot yesterday:
But if next July's anticipated Supreme Court ruling in the MPAA/RIAA vs Grokster/Streamcast goes in favour of the movie and music industries, the heat is going to be on any technology, no matter how benign the intentions of its developer, that nevertheless makes piracy possible.
Which is rather stupid and obtuse. If you're trying to pioneer a novel way to transfer data, then it could be used for piracy. Anything that transfers bits and bytes around can be held liable. So setting this precedent is just PLAIN STUPID. How far will *AA go? Let's say this precedent had already been established... then they could go after Brian Cohen. They could hold him responsible for create an application "makes piracy possible, regardless of his benign intentions". This way the *AA could crush anything that they see as a potential threat.
Vivin Suresh Paliath
http://vivin.net
I like
Yeah, I would have called it Michael Jackson.
#! /bin/bash
/src/mldonkey/distrib/
cd
# --- start mldonkey ---
./mlnet
Buy Steampunk Clothing Online!
Senator Orrin Hatch (Disney-Utah) thanked Mr. Scala for helping to prove his point that P2P was all about molestation and vowed to redouble his efforts to eliminate this erototoxin-spreading technology from the face of the earth.
"First Napster - encouraging the taking of naps, a clear incitement to sloth. Now MoleSter - whose purpose is obvious to anyone who reads its name. And these demon-possessed perverts even have languages for it now; they write in 'python' - the language of the Serpent, and they write in 'perl' - a blasphemous reference to the Biblical story of casting pearls before swine. When, oh, when, will our cries be heard? When, oh, when will we be permitted to protect our citizens from such debauchery? When, oh, when, will the check from MPAA and RIAA clear? We must fight terroristm, because it's for the children!"
http://laguna.fmedic.unam.mx/~daniel/pygtutorial/p ygtutorial/x101.html
I don't see the correlation. Were p2p be made illegal(or whatever ... it's hypothetical), it wouldn't really matter whether it was 15 lines or 15 thousand lines.
Who doesn't like free music?
An Indian-American Hindu committed to non-violent thought/speech/action alarmed by the global explosion of radical Islam
Buy Steampunk Clothing Online!
The fact that it's only 15 lines long, doesn't really say anything. How efficient is it? I've fallen into that trap before. Given the same language, a program isn't necessarily more efficient because it has fewer lines. Did you use a vector when a simple array would have worked? Even better, screw using multiple files, because then you don't have to include any inheritance or extra lines for accessing variables in another file. Just create programs with one file. I'm not trying to insinuate that I'm the programming god, but there is sometimes a difference between a well crafted program and a program with a small codebase.
Does this mean it's time for an International Obfuscated Python Code Contest? (only slightly obfuscated reference to the International Obfuscated C Code Contest )
I believe that the python interpreter (i am assuming that it runs like an interpreter) may be larger than 15 lines.
It also assumes that you have a web server running on your box. What other assumptions are unique to this app? That you have a url defined as a domain?
In other words, I really couldn't run this from a DOS prompt, could I? So, it doesn't really count as a "program". Does it compile into an exe? If not, then what is this article talking about?
It's commonly referred to as "golf". ;)
http://www.perlmonks.org/index.pl?node=golf
I only post comments when someone on the internet is wrong.
Concerning suing users...if someone were to make something like Freenet, only without encryption, would the plausible deniability thing still work? For example, if Soulseek automatically downloaded a Britney Spears song onto my harddrive, then uploaded it to someone else. I'm not really the "true source" of the file, right? Whatever. Discuss!
Monstromart: Where shopping is a baffling ordeal
15 lines, sure, but how many lines of code are in the libraries it imports? More than a few, I suspect.
class _{static void Main(){System.Console.WriteLine("Hello world!");}}
Tech, life, family, faith: Give me a visit
...that Perl is a true write-only language.
Unix: Where
...the T-shirt!
Find free books.
Molester? I hardly knew her!
DAMN YOU OCTODOG! DAMN YOU TO HELL!
Until it's required to have DRM in the OS... And, bans on malicious code... Perhaps a ban on compilers...
Unlikely isn't the word I'd use when we have people who have no clue as to what they're talking about. They'd think they were banning viruses!
Moderate funny ha ha.
Our lawyers are currently perfecting a new TinyLawsuit specifically to defeat your invention. You will like it- Only _10_ lines of legalese!
The ball is now in your court, Mr. Felten!
Regards, The RIAA/MPAA
By you reckoning, you'd need to write the BIOS code as well - don't nit pick.
Here is the Perl p2p one
$p=shift;$a=shift;i(shift);use Socket;socket S,PF_INET,SOCK_STREAM,6; bind S,&a($a);listen S,5;$/=undef;while(@ARGV&&($_="$p $a f".shift)|| accept(C,S)&&($_=)&&close C){m!^(.*?) (.*?) ([e-i])([^/]*)/(.*)$!s&& $1 eq$p&&&$3($2,$4,$5);}sub e{open F,'>',$_[1];print F $_[2];close F} sub f{&s($_,@_)foreach keys %k}sub g{open(F,');close F}sub h{&s($_[0],$_,'i')foreach keys %k}sub i{$k{ $_[0]}=1}sub a{$_[0]=~/^(.*):(\d+)$/&&$2>2e3&&sockaddr_in($2,i
...he'd have modded you down to (Score:-1, Makes Me Look Bad) already.
Do all Slashdot editors check the comments for criticism of themselves, or is it only Michael Sims? If so, they must have a heap of free time.
> Chinese believe that they are entitled to steal softare (i.e. there is nothing wrong with stealing).
Intellectual property (sic), by nature, cannot be stolen. Your right to run a program is not denied by whoever copies the said program from you. They aren't even stealing credit from Microsoft since they do not remove any copyright holders.
The whole concept of property regarding intellectual work is flawed, no wonder there are so many people still trying to define the undefinable.
Shut up. Please.
People Do
TinyP2P requires you specify the server address and port. Um, how is this different then FTPing to a server? Or sending a file over some IM service? Or copying a file over a network share?
I thought the real point of p2p, as in file sharing, was the ability to search many hosts for something, even though you do not know what hosts exist, ideally without even requiring a central server the hosts must register with.
Dan East
Better known as 318230.
What are some other relatively useful applications with very few lines of source code? Looking at the provided links, it has really gotten me interested!
It's completely unreadable as it is, why not just forget carriage returns and claim the "P2P in ONE line of code!".
Peer to peer tech aside, we regulate far simpler actions every day, or at least attempt to. We have laws against shoplifting, far simpler than writing a 9 to 15 line program. We have laws against pedophiles seducing little boys on the internet. That, I assume, is less complicated than writing a 9 line program. These laws don't catch everyone, but they do serve as a deterrent.
Why wouldn't laws against P2P apps be effective? I think that the recent crackdowns on file sharing HAS had a significant impact, and I personally am careful about what I download now, because my cable company (Cablevision) sends me a fat envelope with network monitoring logs showing what I downloaded that they think is copyrighted.
So how many pounds of operating systems does it require?
I am fond of coding, but am not impressed.
When one can prove something useful with 4K RAM, circa '60s, then I will take notice.
--
one of your retired teachers
From the article ...don't pronounce it as three syllables. Every time I look at the word "molester"...
This is a good reason that companies have IT AND Marketing departments...
#!/bin/bash /usr/bin/WhatHeSaid.py
and each line was over 5,000 characters long...
I mod down so you can mod up. Your welcome.
but far be it from me to pick sides; I program in Java ;)
Line 1 - LDA#torrent
Line 2 - STA#torrent
Line 3 - INC
Line 4 - DELRIAAFUCKSLASHDOT
#!/usr/bin/english
use Acronyms;
print "P2P";
paintball
There goes my argument that Python promotes readable code....
"First you gotta do the truffle shuffle."
Did this remind anybody the Therapists Jeopardy skit with a fake Sean Connery on SNL?
What if Digg added local news and a Slashdot inspired comment karma system? ---
http://houndwire.com
Put this together with WyPy, an 11 line python wiki, and you have the beginnings of a 36 line YASNS.
They'll just make it illegal to write and publish software without an engineering license. Afterall, no one but freaks does anything complicated and non-sensual for fun...
Old timers tend to not understand the concept of collaborative coding. My dad is a good example. One time he just looked at me and said that who in their right mind would right a program and NOT charge for it?
Click here or a puppy gets stomped!
Anyone remember The Product? It's a 63.5 kb first person shooter. Pretty neat.
Slashdot covered it a few months ago.
Both these programs remind me of the obfuscated C program contest of years ago. They put multiple lines of code on one text line and use cryptic variable names to save space. They try to be cute to be small. Let's see how small a program can really be written if it is written in a decent style understandable by all. Not everyone knows the more arcane python and perl syntax. But a competent programmer could decipher it if written in a good style. The comment that "any moderately skilled programmer can write one" is BS if it has to be written so cryptically that only the interpreter/compiler can decipher it.
The issue here is quite philosophical. The very nature of the internet is peer to peer. Media pushers still live in the 20th Century world of a broadcast model and think the internet is like television/radio. It is not, and never will be.
Until they swallow that simple fact and get out of denial a lot of people are gonna waste a lot of money and time paying for unworkable broken laws.
That's where the T-shirts with code on them come into play.
Not only will they not go after Bram and BT because it's just shifting bits around (they might as well go after FTP), I wouldn't be surprised if someone tried to hire him or they built off of exisiting code. BT-style file transfer is just far too efficient and effective to stifle, and with a few modifications could make Video-On-Demand viable.
Hell, the only reason I can see why Apple's iTunes/Quicktime division isn't all over him already is because they're probably cooking up their own software, service, and hardware on their own.
---If you can't trust a nerd, who can you trust?
I honestly don't believe people here think clearly, whenever a copyright holder goes after people violating their rights they get all up in arms.
Fact is, I doubt they give two shits about P2P, except that the most popular services are carrying materials they haven't authorized for distribution. If it were about controlling distribution methods, they'd have demanded the entire internet be made illegal years ago.
I get the following error:
TCPA ERROR #12: Unsigned script execution blocked; Trusted Computing violation sent to MS-Patriot Log Authority.
Can anyone help?
Power to the Peaceful
I guess the people who wrote them are "appers" or "scripters" or "serverers" or "clienters". Certainly not "programmers", since they're not writing "programs".
OK, I'll stop now. I'm sure you've had the error of your ways pointed out many times. It's OK to make a mistake; what I'm really amused by is the fact that your post has been modded "Interesting".
The CB App. What's your 20?
Making Pretty Python look like Ugly Perl!! Tsk, tsk... Python Golf has been officially outlawed by moi!!
Honorable Representative/Senator
We the undersigned hope you pass this law to outlaw unregulated programming. Think of the children who are harmed daily so we urge you that you must pass this law so people can't code on their own except under governmental regulations.
Respectfully
**AA
If you'd read Skala's website, you'd see he already addresses your weak argument:
You're using Socket.pm, and it's huge, that's cheating!
Read the fucking code. I'm only using Socket.pm for its defined constants (such as SOCK_STREAM). I could easily eliminate Socket.pm, and save probably another 20 bytes or so, by replacing those constants with the numbers they represent; I have not done so yet only for portability's sake - it might make my code Linux-specific and I'd like to avoid that.
"Truth is not decided by majority vote" consensus gentium -- Norman Geisler
WFW3.11 was P2P. XP has the same functionality as WFW3.11 when it comes to file sharing P2P.
You have Client Server or P2P. If the files are stored on one large server, it's obviously Client Server. If the files are distributed among many clients, it is P2P.
If I share my \\pc\c and you share \\yourpc\c and we swap files, we are doing P2P - using Windows with 0 lines of code.
Point being, if you ban ALL P2P application, Windows is banned. And there is no way to ban ALL P2P traffic as it doesn't look any different from any other traffic. I can do P2P over HTTP tunnels, for example, or STunnel.
Here's a title explanation from the article:
"And we have seen and do testify that the Father sent the Son to be the Savior of the World"
1 John 4:14
RTFA...
Quothe Matthew Skala:
"You're using Socket.pm, and it's huge, that's cheating!
Read the fucking code. I'm only using Socket.pm for its defined constants (such as SOCK_STREAM). I could easily eliminate Socket.pm, and save probably another 20 bytes or so, by replacing those constants with the numbers they represent; I have not done so yet only for portability's sake - it might make my code Linux-specific and I'd like to avoid that."
... 0 lines of code. see it here... http://IKnowTelepathy.com
Rappers do.
# All your files are belong to me :)
See my art -> http://herbevore.deviantart.com
it would take only one line in rebol probably.
and no external libs
Given its small size and the notion behind it of a small network of friends accessing files shared solely for eachother, with some effort could this be the start of the Downhill Battle file sharing proposal?
Sometimes I wish computers were less friendly.
Brian Cohen was, however, the eponymous hero of Monty Python's Life of Brian. Bloody Romans.
you had me at #!
So I take it by his comments that P2P == VPN ? After all, his own description of his software is a VPN.
"he drew his sword Ringil that glittered like ice... and he wounded Morgoth with seven wounds..."
Next up, obfuscated binary:
1 0101
...
0100101111010110
1001101010111101
01010101010
0111100010010111
Attempting to ban P2P is rediculous.
On Skala's page he addresses the question: "Are you related to US Supreme Court Justice Scalia, or some other person with a name equal or similar to "Scala"? No. The correct spelling of my name is all over this Web site." Scrolling to the bottom of that Web site page reveals: "Copyright © 2004 Matthew Skala" To which then reveals /. mispelled Mattew's last name ;) in this story.
~CYD
//Nothing to see here, please move along.
Bob
"Friend Gives me movie to return to rental place and I forgot to go to the rental place" method.
I get more movies that way.
The Kruger Dunning explains most post on
I've added some new features to your wonderful program, which I too am releasing under the GPL. I call it:
"Breaking in to the Neighbor's House to steal a Movie".
http://www.ioccc.org/ ..
if only this were written in C!
Seriously, though, if anyone working for me wrote code like that.. they'd be fired.
I am the maverick of Slashdot
Someone needs to get all this kind of information to the US supreme court before they hear that Grokster case. They need to have a technical understanding of this stuff.
Professor Lessig,
I was also thinking you could write an amicus curie brief for the court on this case. What do you think? Maybe someone could send the justices some of your books too like "free culture"?
People start getting this info the the supreme court. Also could someone get this comment to Dr. Lessig?
--
Sorry I'm half joking here, but the justices do need to see stuff like this somehow.
From the article:
(Each line has 80 characters or fewer. The first line doesn't count -- it's a label for human readers and is ignored by the computer.)
Oh great. It was the ONLY line I could understand!
Hey I wouldn't have minded if the author wrote a *READABLE* version of the program! It looked more like a contestant for the obfuscated C programming contest.
RTFL.
He actually talks about that problem on the webpage. The only thing he imports is Socket, and he only uses the constants from it, to maintain cross-platform compatibility. If he dumped the Use Socket line and changed the constants to the numbers they represent, it'd still work but might become Linux specific.
So setting this precedent is just PLAIN STUPID. How far will *AA go? Let's say this precedent had already been established... then they could go after Brian Cohen. They could hold him responsible for create an application "makes piracy possible, regardless of his benign intentions". This way the *AA could crush anything that they see as a potential threat
I don't know about you, but I'm thinkin the FAA will be pretty ticked.
Don't ping my cheese with your bandwidth!
the 9 line MoleSter, written in Perl.
That can't be perl, there's comments and explanations all over it!
$8.95/mo web hosting
I thought the real point of p2p, as in file sharing, was the ability to search many hosts for something, even though you do not know what hosts exist, ideally without even requiring a central server the hosts must register with.
That's just what these programs are doing. You connect to any host on the network, then can search and download files from any other hosts on the network. No central server.
A connects to B.
C connects to A.
D connects to C.
D and B can now search for and share files.
These programs implement that. They are both client and server. That's what P2P is all about.
Matthew Scala, a reader of Freedom to Tinker, has responded with the 9 line MoleSter, written in Perl.
There have been discussions recently about potential employers doing a Google search on job applicants, so the way I see it Mr. Scala's either very smart or very stupid.
Very stupid, for the fact a lot of searches will put "Matthew Scala" and "molester" together on the same page.
Very smart, because this tactic will bury any evidence of his pedophilia under a pile of MoleSter links and pages.
=P
± 29 dB
In Windows, just create a public share on your C: drive. As long as you're not blocking port 445, you can trade files with the whole world that way.
I'm not saying this is a good idea, just pointing out that you don't need to write a program to do it.
The most rabid believers in American Exceptionalism are the exact same people whose policies are destroying it.
This idea of number of lines seems like an odd/arbitrary metric to me. I took a look at MoleSter and I am impressed with its conciseness. But 9 lines seems somewhat arbitrary, as the lines are simply packed and reformated to fit in a certain width.
It seems to me that number of statements would be a better metric (semi-colons in perl?). For MoleSter this would be about 25 statements (without punishing for subroutines). This method has the advantage of not punishing for using longer variable/function names.
Of course, it is always debatable exactly what constitutes a statement in each particular language.
Wanted: witty unique signature. Must be willing to relocate.
Right! It's like suing a gun manufacturer for a hold-up. These tiny P2P programs are the spud guns of file sharing!
Did anyone show him how to change the font size and reduce the border size? Maybe also change the kerning and i think we should be able to get that code down to 3, who knows maybe even 1.
Can we sell T-shirts with this code on them? Go nuts, it's public domain. But please don't lead your customers to believe that I'm getting a cut of the proceeds unless you give me one.
But then won't they have to make the source code available to people who buy the shirt?...Oh wait, it's not GPL...nevermind
Coder's Stone: The programming language quick ref for iPad
i never liked email anyway
Technically, That's P2P, mind you.
Hello people, remember a little command called 'nc'?
receiving end: nc -p <ListenPort> -l > <FileReceived>
sending end: nc <IPofReceivingEnd> <ListenPort> < <FileToSend>
If you're thinking, "the python and perl scripts do much more"... I'm sure you could be creative in your shell scripting to accomplish the same thing using 'nc'. I have, and it works smooth as butter every time. The reason I bring NetCat into the discussion is not to shy folks away from these python and perl scripts. Truth be told, you will benefit in many more ways with the two interpreters vs 'nc'. However, 'nc' is such a small footprint. By using 'nc' you don't have to worry about python or perl being installed. Just a single loney powerful binary file called "nc".
...in taking a program and just removing all the newlines and saying "hey, I did a P2P program in 9 lines"? Its not really 9 lines, its 9 visual lines but far more executable lines.
http://www.froogle.com
I needed to move some data off some IBM hardware that was falling apart (literally) onto my new eMac. For various reasons I couldn't just connect a cable between them. So I connected the laptop to my old dialup isp (in another state) and the eMac I had on ADSL. In total I moved about a gig of data with it.
:D Booyah!
Don't be too impressed with the Perl version, its actually 42 lines long, but then condensed down to 9 lines through the power of removing whitespace and line breaks.
Also, from the sounds of it, the Java version beats the living sh!t out of the Perl version as far as performance goes.
So here's my Java version (of the mac client, the serversocket was trivial). I don't think this was the final version, so it might have some bugs, but its close. For comparison it would be about 17 lines of code by the way those guys are counting. Total characters with whitespace (but not linebreaks) removed: 1248. It could be made even smaller if I wanted to, eg choosing one letter variable names, not being in a package... you know the drill. I removed the comments to get a better idea of the number of characters.
package rick.network; import java.io.*; import java.net.*; public class DocPuller { public static String baseDir = "//users//******//laptop//"; public static String laptopAddress = "203.221.67.2"; public static int docsock = 1234; public DocPuller(String fileName) { try { File f = new File(baseDir + fileName); Socket sock = new Socket(laptopAddress, docsock); sock.getOutputStream().write((fileName + "\n").getBytes()); readFile(sock, f); } catch (Exception e) { System.out.println("oops: " + e); } } public static void main(String[] args) { try { if (args.length == 0) { System.out.println("Address: " + InetAddress.getLocalHost()); return; } } catch (Exception e) { System.out.println("oops: " + e); } DocPuller dp = new DocPuller(args[0]); } public void readFile(Socket sock, File f) { try { FileOutputStream fos = new FileOutputStream(f, true); byte[] ba = new byte[100000]; BufferedInputStream bufin = new BufferedInputStream(sock.getInputStream()); int n = 0; n = bufin.read(ba); while (n == ba.length) { fos.write(ba); fos.flush(); n = bufin.read(ba); } if (n > 0) { fos.write(ba, 0, n); fos.flush(); } fos.flush(); fos.close(); } catch (Exception e) { System.out.println("problem while reading/writing file: " + e); } } }
It feels good to layeth the coding smack down. :D
Tinyp2p proves that software aspect of p2p networking is accessible to the vast majority of us and that means that the IP police will never have a single simple target to chase.
But it is the hardware part of p2p that is scary. All p2p networks can come down if our broadband providers decide to block the ports normally used for it or to take any other restrictive measure.
The right to digitally communicate and associate, is seriously at risk! I have wrote more extensively about it here: http://slashdot.org/~fccoelho/journal/
Is that the network for kiddie pr0n?
....I also wrote a very small p2p program while I was getting my CS degree in Houston (UHD). It was written in perl and was written specifically for a one-tome demonstration for a pre-senior project class. It was specically written for a particular computer lab/classroom at the school.
I told one of my professors there what I was doing, and he replied, "But is it legal?"
In reply to him, I say, yes, Ongard, it is legal. At least so far....
eat shiat and bark at the moon
But it's not "15 lines of code" you have to audit.
It's those 15 lines, plus the python runtime, plus the source code of the imports: import sys, os, SimpleXMLRPCServer, xmlrpclib, re, hmac.
...the government has banned growing a plant (marijuana) which any fool can do with very little effort (or no effort if the wind blows in your favor). For some reason I don't think ease of commiting the act is going to stop a law from being created.
The Perl version is not a more compact achievement. As usual, it just packs a number of Perl statments on one "line." The Python version is more honestly compact *and* more understandable.
The whole debate ( and silly court cases ) about p2p is reaching critical mass soon.
But is the p2p concept not a simple fact'o'life In this generation ?
An unstopable thing that the "old" folks fight just like "we" shall fight new things when we get around to it later ?
It's the 50's just with broadband !
-- forget
Excuse me, but I think the e() has a pretty glaring security hole: What happens if the expected file is called ~/.muttrc? I could lose all my mail!
Or if it's "molester"? Aha...arbitrary code execution the next time he starts his client!
--LWM
I don't think anybody is seriously expecting to ban P2P anyway. Bittorrent is genuinely used to distribute Linux distros, foe example, and I wouldn't be surprised if there have been a number of legitimate CDs made available legitimately by amateur bands and movie makers
I modded this comment based on your sig. Yes, I know you're not supposed to do that, but I love irony too much. Besides, what the heck else am I gonna do with all these mod points? They give me new ones every other day! ;)
'everything is legal if the government can see you' - krs-one
These mini-P2P programs may not be useful for serious media sharing, but I can think of a real-world application - distribution of banned text (articles, newspapers, etc.) in the PRC and other repressive states. The software's tiny - small enough that anyone with Python or Perl installed could just keep the program on a folded sheet of paper, type it in when they want to use it, and delete the program when they were done. If you got in trouble, just burn the paper.
I'm the stranger...posting to
P2P is the marijuana of the 21st century in the sense that it is an activity done by millions of people who don't think there is anything wrong with doing it. And it has been (actually in this case, will be) made illegal by clueless legislators prompted by outlandish claims by business groups.
Now you have a classic situation where a vague law can be focused on a large group of people for political reasons. Individuals can be selected either randomly or because of their unrelated political activities or beliefs and be fed into the legal machinery for the 'criminal' activity of using P2P.
Given the for-profit corporate prison industry in the USA and the oversupply of greedy lawyers, this looks like a new profit center focused on young people in the same way that the marijuana industry turned out to be extremely profitable for the lawyer-corporate prison coalition.
Make P2P vaguely illegal.
Make it incredibly easy to do.
Select 100 young people at random.
Check for P2P activity.
If yes, offer them a deal:
go to prison for your 'crime'
(the corporate prison makes $30,000 per year)
-or-
pay a $10,000 fine to the RIAA and turn in several friends doing P2P. (keeps the chain going).
-or-
pay a lawyer $20,000 and get probation. ($10,000 goes to the lawyer and $10,000 goes to the judge), along with turning in several friends using P2P.
You can see how this can become very profitable for the lawyers, RIAA, and prison corporations. Each will make sizable bribes (campaign contributions) to politicians to keep the laws against P2P quite strict, in the name of fairness to musicians and artists.
(remove spaces first, save as a
"Where are we going, and why am I in this handbasket?"
p2p.Make() p2p.Connect(myFriends) p2p.Share(pr0n) p2p.Hide(New Regex("[[:alpha:]][[:alpha:]]AA")) p2p.Rawr();
Look! 5 lines of filesharing goodness!
Soylent Green illegal!
Soylent Green is illegal! Everybody! Stop eating it! Soylent Green is illegal!
COUNTDOWN ABORTED
Code is left intact, but here is the whitespace massaged into a more widely-accepted (and readable) convention. You see, Python isn't -that- sensitive to whitespace! ;-)
myU, prs, srv = ("http://"+ar[3]+":"+ar[4], ar[5:], lambda x:x.serve_forever())
# tinyp2p.py 1.0 (documentation at http://freedom-to-tinker.com/tinyp2p.html)
import sys, os, SimpleXMLRPCServer, xmlrpclib, re, hmac # (C) 2004, E.W. Felten
ar, pw, res = (sys.argv, lambda u:hmac.new(sys.argv[1],u).hexdigest(), re.search)
pxy, xs = (xmlrpclib.ServerProxy, SimpleXMLRPCServer.SimpleXMLRPCServer)
def ls(p=""):
return filter(
lambda n: (p == "") or res(p, n),
os.listdir(os.getcwd()))
if ar[2] != "client": # license: http://creativecommons.org/licenses/by-nc-sa/2.0
def pr(x=[]):
return ([(y in prs) or prs.append(y) for y in x] or 1) and prs
def c(n):
return ((lambda f: (f.read(), f.close()))(file(n)))[0]
f = lambda p, n, a: \
(p == pw(myU)) and (((n == 0) and pr(a)) or ((n == 1) and [ls(a)]) or c(a))
def aug(u):
return ((u == myU) and pr()) or pr(pxy(u).f(pw(u), 0, pr([myU])))
pr() and [aug(s) for s in aug(pr()[0])]
(lambda sv: sv.register_function(f, "f") or srv(sv))(xs((ar[3],int(ar[4]))))
for url in pxy(ar[3]).f(pw(ar[3]), 0, []):
for fn in filter(lambda n: not n in ls(), (pxy(url).f(pw(url), 1, ar[4]))[0]):
(lambda fi: fi.write(pxy(url).f(pw(url), 2, fn)) or fi.close())(file(fn, "wc"))
It will however be several million characters long.
/etc/init.d/nfs start
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Die C# Die");
}
}
Haiku about 15 line P2P app, only 3 lines. ^_^
Slowly Spinning Peers,
Ugly, but Minimized.
Exercise in Small.
"A Goddess rarely smiles for she is forced by others to be an island unto herself." - Zephiris
The RIAA and MPAA are now suing eyeballs, because they can be used to watch pirate movies, ears, because they can be used to listen to downloaded mp3s, and brains, because they can be used to store the above without paying licensing or royalties.
Voodoo Girl is the bomb!
Maybe we are all missing the point, as just about every post above me includes "your missing the point" in it somewhere. Alternatively, maybe we have different points!
As for this argument about what the point is, in my opinion it has nothing to do with how much cheating his code has in it and everything to do with that p2p isn't hard to do, as he claims the point is.
(point-point-ah, my eye!)
Anyone have a public IP and any good pr0n they want to share?
"What do you despise? By this are you truly known." --Princess Irulan, Manual of Muad'Dib
/)
RIAA And MPAA Team To Crack Down On Secret Piracy Tool: "Copy" Command
"A great democracy must be progressive or it will soon cease to be a great democracy." --Theodore Roosevelt
Everything stuffed together to be a :line:
I'm sure it can all be put into 1 line depending on the language. So what? How about measuring in the number of operations?
I'ts all very insteresting to read about this, but I'm wondering... seems creating P2P is very simple, yet why takes it so long for people to take up the chalenge of making a 'small social network' P2P-system?
Wasn't it on this veryè same slashdot, that not too long ago an article was mentioned about a site who was willing to pay a considerable amount of money to any coder willing to work on a OSS P2P system annex IM which was meant to be used in a small network of friends, and thus, below the radar of RIAA and co.
I gather the author in question isn't very interested in money, at least compared to 'status among peers' (something that seems to be typical of good coders working on OSS projects, like Linus). But I can't imagine that NO coder (at least the last time I checked) has taken that offer up for 1000 bucks, while this one makes a simple P2P prog in a matter of days, just to prove a point, or even just for the fun of it.
I'm not sure how it was called again, but some probably will remember and maybe post a link to it...now, the only thing to find are skala-type dudes - and getting a nice bonus on top. Volunteers?
--- "To pee or not to pee, that is the question." ---
I gotta admit that that's pretty kewl but it's so easy to write P2P software, I write me own Chat, SE Reporting, URL Ripping software, it's so simple. I even go as far as to develop my own encryption algorithm based on RC4 but seriously modified, e.g. rather than having a Key of 256, (0 - 255), I have 65026, (0 - 65025), with a lesser percentage of 0 ascii codes than RC4.
I wrote it in bash.
/etc/init.d/httpd start
#!/bin/bash
-pyrrho
Man, those guys must be lvl 40 coders who have amulets of quick typing +8!
How many lines do we need to program a mind nowadays?
The Christian in me says it's wrong, but the corrections officer in me says, 'I love to make a grown man piss himself.'
I managed to shave off a few strokes, getting it down to eight lines
o se F}sub h{_($_[0],$_,'i')for keys%k}subn et_aton($1)
... : ... ? ... operator, which usually saves strokes, and I'm
(at no more than 80 chars per line). I'm sure someone can do better,
but here's what I've got so far:
$p=shift;$a=shift;i(shift);use Socket;socket S,PF_INET,SOCK_STREAM,6;bind
S,&a($a);listen S,5;$/=$3;while(@ARGV&&($_="$p $a f".shift)||accept(C,S)&&($_=
<C>)&&clo se C){m!^(.*?) (.*?) ([e-i])([^/]*)/(.*)$!s&&$1 eq$p&&&$3($2,$4,$5)}sub
e{open F,">$_[1]";print F $_[2];close F}sub f{_($_,@_)for keys%k}sub g{open(F,
"<$_[1]")&&_($_[0],$a,"e$_[1]",<F>);cl
i{$k{$_[0]}=1}sub a{$_[0]=~/^(.*):(\d+)$/&&$2>2e3&&sockaddr_in($2,i
)}sub _{socket X,PF_INET,SOCK_STREAM,6;$w=shift;if(connect X,a$w){print X
"$p $_[0] $_[1]/$_[2]";close X}else{$k{$p}}=$7}
The word "shift" at five strokes is still in there four times, but it's not
obvious how to improve on that. There are more things that can be done,
though. For example, the if/else stuff can probably be converted to use
the trinary
almost sure at least one of those foreach loops could be made into a map,
which also usually saves strokes. The Socket constants are also eating
a few more strokes than is strictly necessary, and I'm virtually certain
it's possible to reduce the number of variables by taking advantage of
implicit $_ in a couple more cases... it ought to be possible to get this
thing down to five lines, maybe four, and put it in an email signature.
Cut that out, or I will ship you to Norilsk in a box.
Now all we need to do is figure out how to get the users to sue their peers...
Can you be Even More Awesome?!
Usenet...the comeback kid
In soviet russia, Perl writes you!
Why not just put an open SMB on a internet port, and have something that registers your address so other users can get access to your whole HDD.
thank God the internet isn't a human right.
Sure making a simple P2P program is easy, in the same way that making a simple graphics program is easy. To anyone who's read a bit about networking, it's very clear how to write such a program. The real challenge with P2P is not making a file-sharing program but making it efficient and secure.
In fact I think it is definitely unfair to sue P2P program developers, while suing users and torrent sites is more fair. If suing users means some bad publicity, they deserve it, just like drug companies suing African countries for violating their patents on some AIDS drugs deserve some bad publicity even though legally they may win. Otherwise it would be unfair to those who decides not to sue. And it should be up to RIAA and the likes to choose targets that gives them the most profit and hurts publicity the least. In this way, suing children is just stupid, while suing tool makers are plain unreasonable.
"I wired my three-wire peer-to-peer serial cable to illustrate the difficulty of regulating peer-to-peer hardware."
I mean, come on. Peer to peer can mean about anything, really.
"What's the frequency Kenneth?"
a real perl master writes like this: /dev/urandom
perl
#!/usr/bin/perl
u 87 srthmn90;ps394b7-6vh0ae6se0n89789t75j890t67scj8906 7j890e54t890;5478n35890904hn907t85j90670w9-57-xfg9 0hjx;omnxrt9bn0ps54;s907n-679s-90xe54/6w547/7589vj 0s9-78se-06vw346hbn87n98i7eu6;463g3w6g6v6u45betyv4 yc45y4y5s7n86uijy463q4awy;4w57ne568une5j7vc7uyh35x jh7z6jx5uj6ukdtmcdryjtu;68ne578iyjvyhdrch6ug37eb64 n84mw6m8s4r6i4rt6; :)";
:)
fjdohsb0y[tu34qtyjhq5ykl2yjh4u5iongvwy5iopy9uy7
print "hehehe
oh crap...make it 5 with word wrap turned on
Find a job you like and you will never work a day in your life.
Actually, I thought the term "line" was supposed to mean "statement" when you start using it as a metric for measuring program size. (In other words, it originated from times when programming languages only allowed one statement per line.)
I remember a presentation in one of my classes where the presenter said her company defines "line" this way when they measure the size of their code. She said there was actually a more complicated definition that they used but it was basically one statment equals one "line".
Who
Gives
A Fuck?
Until now I would have said there could never be an obfusticated Python contest, but now I've been proven wrong... That's like a spicy hot banana cream pie bakeoff...
The problem here is that a patent doesn't last enough, as U.S. patents are renewable only to 20 years after filing. A patent may have been enough in the 1800s when a copyright was renewable to 28 years, but now that Disney and the rest of the MPAA have conned Congress into giving the commons a life+70 jail sentence, it won't work.
/Mikael
Greylisting is to SMTP as NAT is to IPv4
MoleSter would be a damned fine entry for the Annual Obfuscated Perl Contest. I admire the author's skill, but since the purpose of the "9 lines" headline is to advertise the capabilities of Perl, I have to wonder whether he has succeeded:
p $a f".shift)||accept(C,S)&&($_=)&&close' ,split'\.',$`}sub
$p=shift;$a=shift;i(shift);socket S,2,1,6;bind S,&a($a);listen
S,5;$/=undef;while(@ARGV&&($_="$
C){m!^(.*?) (.*?) ([e-i])([^/]*)/!s&&$1 eq$p&&&$3($2,$4,$');}sub e{open
F,'>',$_[1];print F $_[2];close F}sub f{&s($_,@_)for keys %k}sub
g{open(F,');close F}sub
h{&s($_[0],$_,'i')for keys %k}sub i{$k{$_[0]}=1}sub
a{$_[0]=~/:/;pack'CxnC4x8',2,$
s{socket X,2,1,6;$w=shift;if(connect X,&a($w)){print X
"$p $_[0] $_[1]/$_[2]";close X}else{undef $k{$p}}}
The same comments apply (to a lesser extent) to TinyP2P and Python.
Can't we find a better measure of conciseness and expressiveness than the character count - one that is consistent with good programming practice, such as writing reusable code?
I don't have to write any lines of code in my wonderful Windows environment... just check this little box that says "enable file and printer sharing", so take that you Linux zealots.
Hah! Even better! According to Spybot, someone has already shared all my files, with NO user interaction! Beat that!
I think the Python solution has a security bug that allows attackers to retrieve all files that the user under which the server is run has access to by supplying a filename like "../foo". Here's a replacement version in Ruby:
I'm using DRb, a library for OOP-style remote procedure calls, instead of XML-RPC.
In case this posting gets slashdotted or screwed up by the crazy space insertation engine the code is also available here. (with syntax highlighting!)
Oh, and for the trolls: I usually don't write obfuscated, golfed Ruby code, but the language certainly won't stop me from doing so when I need to do so for reasons of holy language wars.
Overloading. Ever heard of it? QED.
You're using Socket.pm, and it's huge, that's cheating! Version 0.0.2 no longer uses Socket.pm. As for version 0.0.1, I should have read the fucking code myself before posting the previous version of this answer, because I forgot that it actually does use the sockaddr_in packing routine as well as symbolic constants. I still think that even in 0.0.1 I did better than Felten and Halderman, who imported an entire XMLRPC library.
Comparing it to Windows will be a moot point, since El Dorado is going to have a 40% larger code base than XP.
Thats not a 15 lines Python program, but a 100 lines program reformatted to be unreadable and fitting on 15 lines. Done by using an arbitrary, probably 70 characters, line length as artificial line counter.
:D
Nevertheless good work. I jsut wonder what the function f() is doing
angel'o'sphere
Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
the 2nd amendment should be broadened to cover code, compilers, computing in general;-)
*** *** You're just jealous 'cause the voices talk to me... ***
Make that 13 piece-of-shit overcluttered lines of code. If the author had used adequate spacing, it would have been well over 40.
import sys,os,SimpleXMLRPCServer as S,xmlrpclib as L,re,hmac;T=lambda x=[]:([(y: //"+V[e r"!=V[2]and([[file(F,"wb").write(X(l).F ).data)for F in[i for i in X(l).f(P(l),1,V[4])[0]if not i in U()]]forM LRPCServer((V[3],int(V[4]
:)
in s)or s.append(y)for y in x],s)[1];f=lambda p,n,a:p==P(M)and{0:T,1:lambda a:[U
(a)]}.get(n,lambda n:L.Binary(file(n,'rb').read()))(a);U=lambda p='':[n for n in
os.listdir(os.getcwd())if re.search(p,n)];O=lambda u:(u==M and T())or T(X(u).f(P
(u),0,T([M])));P=lambda u:hmac.new(V[1],u).hexdigest();V=sys.argv;M="http
3]+":"+V[4];X=L.ServerProxy;s=V[5:];"serv
f(P(l),2,
l in X(V[3]).f(P(V[3]),0,[])],sys.exit(0));i=S.SimpleX
)));T()and map(O,O(T()[0]));i.register_function(f,"f")or i.serve_forever();('_')
It still has security hole, but it can transfer binary file now.
- Tokigun (Kang Seonghoon)