1
+ #!/usr/bin/env node
2
+
3
+ /**************************************************************************************
4
+ *
5
+ * Command line URL pic zip decompressor. Use it like this:
6
+ *
7
+ * echo "/bash.html?zip=eDdyMjV4OGUxeDdyNnc4cjExeDhlMXg3cjd3NnIxMng4ZTF4N3I4dzRyMTN4OGUxeDdyOHc0cjEzeDhlMXg3cjh3NHIxM3g4ZTF4N3I4dzRyMTN4OGUxeDdyOHc0cjEzeDhlMXg3cjh3NHIxM3g4ZTF4N3I4dzRyMTN4OGUxeDdyOHc0cjEzeDhlMXg3cjh3NHIxM3g4ZTF4N3I4dzRyMTN4OGUxeDdyOHc0cjEzeDhlMXg3cjh3NHIxM3g4ZTF4N3I4dzRyMTN4OGUxeDdyOHc0cjEzeDhlMXg3cjh3NHIxM3g4ZTF4N3I4dzRyN3cxcjV4OGUxeDdyOHc0cjZ3MnI1eDhlMXg3cjd3MTNyNXg4ZTF4N3I2dzE0cjV4OGUxeDdyMjV4OA==" | xargs ./zip2bash.js | bash
8
+ *
9
+ **************************************************************************************/
10
+
11
+ //base64 parse
12
+ function atob ( str ) {
13
+ return new Buffer ( str , 'base64' ) . toString ( 'binary' ) ;
14
+ }
15
+
16
+ //Decompress the zip in the querystring
17
+ var decompress = function ( url ) {
18
+ var rqs = / [ ? | & ] z i p = ( [ ^ & ] * ) / ;
19
+ var rsp = / ( [ a - z ] \d * ) / ;
20
+ var exe = rqs . exec ( url ) ;
21
+ var pic = [ ] ;
22
+ if ( exe && exe . length > 1 ) {
23
+ var zip = decodeURIComponent ( exe [ 1 ] ) ;
24
+ var tmp = [ ] ;
25
+ try {
26
+ zip = atob ( zip ) ;
27
+ tmp = zip . split ( rsp ) ;
28
+ for ( var i = 0 , l = tmp . length ; i < l ; i ++ ) if ( tmp [ i ] . length ) pic . push ( tmp [ i ] ) ;
29
+ } catch ( ex ) { }
30
+ }
31
+ return pic ;
32
+ } ;
33
+
34
+ //parse and return the image script
35
+ var parse = function ( url ) {
36
+
37
+ var img = decompress ( url ) . join ( ' ' ) ;
38
+
39
+ return `
40
+ #Background Colors
41
+ E=$(tput sgr0); R=$(tput setab 1); G=$(tput setab 2); Y=$(tput setab 3);
42
+ B=$(tput setab 4); M=$(tput setab 5); C=$(tput setab 6); W=$(tput setab 7);
43
+ function e() { echo -e "$E"; }
44
+ function x() { echo -n "$E "; }
45
+ function r() { echo -n "$R "; }
46
+ function g() { echo -n "$G "; }
47
+ function y() { echo -n "$Y "; }
48
+ function b() { echo -n "$B "; }
49
+ function m() { echo -n "$M "; }
50
+ function c() { echo -n "$C "; }
51
+ function w() { echo -n "$W "; }
52
+
53
+ #putpixels
54
+ function u() {
55
+ h="$*";o=$\{h:0:1};v=$\{h:1};
56
+ for i in \`seq $v\`
57
+ do
58
+ $o;
59
+ done
60
+ }
61
+
62
+ img="${ img } "
63
+
64
+ for n in $img
65
+ do
66
+ u $n
67
+ done
68
+ e;
69
+ exit 0;
70
+ ` ;
71
+ } ;
72
+
73
+ console . log ( parse ( process . argv [ 2 ] ) ) ;
0 commit comments