Tag Archives: coding

Upgrade Python packages at using pip

As you read in the title above; to update your python packages via pip:

for Linux/*nix:

p/s: you may need to run as sudo. Probably.

for Windows:

Credit: http://stackoverflow.com/questions/2720014/upgrading-all-packages-with-pip

Shell script fails: Syntax error: “(” unexpected

The error when executing the bash code:

The script does not begin with a shebang line, so the kernel executes it with /bin/sh. On Ubuntu, /bin/sh is dash, a shell designed for fast startup and execution with only standard features. When dash reaches the line, it sees a syntax error: that parenthesis doesn’t mean anything to it in context.

Since dash (like all other shells) is an interpreter, it won’t complain until the execution reaches the problematic line. So even if the script successfully started at some point in your testing, it would have aborted once the problematic line was reached.

The shebang line must be the very first thing in the file. Since you use bash features, the first line of the file must be #!/bin/bash or #!/usr/bin/env bash.

Credit: http://unix.stackexchange.com/questions/45781/shell-script-fails-syntax-error-unexpected

Python Error – InsecurePlatformWarning

There is one time I see this kind of error:

If you’re on ubuntu, you may run into trouble installing pyopenssl, you’ll need these dependencies:

You only need to install the security package extras:

or, install them directly:

Requests will then automatically inject pyopenssl into urllib3

Credit: http://stackoverflow.com/questions/29134512/insecureplatformwarning-a-true-sslcontext-object-is-not-available-this-prevent

Unable to run autoconf on configure.ac

configure.ac:15: error: possibly undefined macro: AM_INIT_AUTOMAKE
If this token and others are legitimate, please use m4_pattern_allow
See the Autoconf documentation

You can use this solution to solve it.
– sudo pacman -S pkg-config xorg-server-devel libtool automake
– libtoolize –force
– vim configure.ac
– Add AC_CONFIG_MACRO_DIR([m4]) into configure.ac
– libtoolize –force
– aclocal
– autoheader
– automake –force-missing –add-missing
– autoconf

After that, just run ./configure as usual.

socket.io’s `listen()` method expects an `http.server` instance

 For people that has this problem when using node.js & express app, here I show you way to solve it.

The error that you will see upon start the node.js:

Warning: express.createServer() is deprecated, express
applications no longer inherit from http.Server,
please use:

  var express = require(“express”);
  var app = express();

Socket.IO’s `listen()` method expects an `http.Server` instance
as its first parameter. Are you migrating from Express 2.x to 3.x?
If so, check out the “Socket.IO compatibility” section at:
   info  – socket.io started

The solution is to change this line:

var app = require(‘express’).createServer(),
    io = require(‘socket.io’).listen(app),
    scores = {};                               

// listen for new web clients:

to this:

var express = require(‘express’),
    app = express()
  , http = require(‘http’)
  , server = http.createServer(app)
  , io = require(‘socket.io’).listen(server);

// listen for new web clients:

Try to start again. Problem solve. 🙂

CSRF in SpiceFuse Shoutbox (MyBB)

bagi sape2 yg ade forum yg berasaskan MyBB, dan yg menggunakan SpiceFuse Shoutbox, baik korg baca bnd ni..
sbb ade bnd yg menarik kat sini.. 🙂
bnd ni Johnburn dr tbd.my yg jmp.. jd aku share kn kat sini..
special thanx to Johnburn utk artikel & solution ni.. 🙂

The stories:
Tadi xda keje aku tgk2 code mybb dengan target nk bypass xss filter mybb melalui bbcode dia. dlm aku tgk2 tu aku nmpk satu bnda yg agak menarik pada code shoutbox (aku install plugin SpiceFuse Shoutbox yg sama mcm kt TBD and my0d). Plugin ni vulnerable kepada CSRF melalui image tag.

Jika user post yang berikut kat shoutbox, mana2 user len yg view shoutbox secara automatik akan turut post sebarang post jika browser diset untuk load image (default).


Quick Fix:
Bleh elak dengan menggunakan token pada shoutbox. Untuk tmbah token, bleh ikut yg berikut:

Edit file ni:

cari line berikut:

dan gantikan dengan line ni:

Edit file ni:

cari line:

tambah line berikut selpas code di atas:

cari line berikut:

dan gantikan dengan line ni:

Edit file ni:

cari line berikut:

tambah code berikut selepas baris code di atas:

p/s: mungkin perlu reactivate blk shoutbox supaya apa yg diubah pada template untuk take effect.