Skip to content

Instantly share code, notes, and snippets.

@bingeboy
Last active December 18, 2015 19:49
Show Gist options
  • Save bingeboy/5835495 to your computer and use it in GitHub Desktop.
Save bingeboy/5835495 to your computer and use it in GitHub Desktop.
2012 Hackathon Olymipcs Entry
var fs = require('fs')
, http = require('http')
, util = require('util')
, path = require('path')
, Combinatorics = require('./combinatorics.js').Combinatorics
, request = require('request')
, ipContainer = [], url2Test, ipContainer2 = []
, cmb = Combinatorics.permutation(['0','1','8','16','46','74','96','106','109','126','127','186','192','255'], 4);
cmb = cmb.toArray();
for(var i =0; i < cmb.length; i++){
result = cmb[i].join(".");
ipContainer.push(result);
}
for (var i=0; i < ipContainer.length; i++) {
url2Test = 'http://'+ipContainer[i];
//applied filters
if(url2Test.substring(0, 11) !== "http://255." && url2Test.substring(0, 14) === "http://106.186" && url2Test.charAt( url2Test.length-1) != 1 && url2Test.charAt( url2Test.length-1) != 0) {
url2Test += "/hackerolympics.json";
console.log(url2Test);
request.post(url2Test,
//callback
function (error, response, body) {
if (!error && response.statusCode == 200) {
console.log("This is the IP: ", url2Test, "BODY:", body, response);
}else{
// console.log("ERROR: ", url2Test);
}
});
ipContainer2.push(url2Test);
}
}
@bingeboy
Copy link
Author

warning this doesn't always work.... I guess I was lucky to get my response back before loop. I think the call should be sync instead of async.

@bingeboy
Copy link
Author

This is the IP: http://255.192.186.127 BODY: { _readableState:
{ highWaterMark: 16384,
buffer: [],
length: 0,
pipes: null,
pipesCount: 0,
flowing: false,
ended: true,
endEmitted: true,
reading: false,
calledRead: true,
sync: false,
needReadable: true,
emittedReadable: false,
readableListening: false,
objectMode: false,
defaultEncoding: 'utf8',
ranOut: false,
awaitDrain: 0,
readingMore: false,
decoder: null,
encoding: null },
readable: false,
domain: null,
_events:
{ end: [ [Function: responseOnEnd], [Function], [Function] ],
readable: [Function],
close: [ [Function], [Function] ],
data: [Function] },
_maxListeners: 10,
socket:
{ _connecting: false,
_handle:
{ fd: 22,
writeQueueSize: 0,
owner: [Circular],
onread: [Function: onread],
reading: true },
_readableState:
{ highWaterMark: 16384,
buffer: [],
length: 0,
pipes: null,
pipesCount: 0,
flowing: false,
ended: false,
endEmitted: false,
reading: true,
calledRead: true,
sync: false,
needReadable: true,
emittedReadable: false,
readableListening: false,
objectMode: false,
defaultEncoding: 'utf8',
ranOut: false,
awaitDrain: 0,
readingMore: false,
decoder: null,
encoding: null },
readable: true,
domain: null,
_events:
{ end: [Object],
finish: [Function: onSocketFinish],
_socketEnd: [Function: onSocketEnd],
free: [Function],
close: [Object],
agentRemove: [Function],
drain: [Function: ondrain],
error: undefined,
connect: undefined },
_maxListeners: 10,
_writableState:
{ highWaterMark: 16384,
objectMode: false,
needDrain: false,
ending: false,
ended: false,
finished: false,
decodeStrings: false,
defaultEncoding: 'utf8',
length: 0,
writing: false,
sync: false,
bufferProcessing: false,
onwrite: [Function],
writecb: null,
writelen: 0,
buffer: [] },
writable: true,
allowHalfOpen: false,
onend: null,
destroyed: false,
errorEmitted: false,
bytesRead: 270,
_bytesDispatched: 101,
_pendingData: null,
_pendingEncoding: '',
parser: null,
_httpMessage:
{ domain: null,
_events: [Object],
_maxListeners: 10,
output: [],
outputEncodings: [],
writable: true,
_last: false,
chunkedEncoding: false,
shouldKeepAlive: true,
useChunkedEncodingByDefault: true,
sendDate: false,
_hasBody: true,
_trailer: '',
finished: true,
_hangupClose: false,
socket: [Circular],
connection: [Circular],
agent: [Object],
socketPath: undefined,
method: 'POST',
path: '/hackerolympics.json',
_headers: [Object],
_headerNames: [Object],
_header: 'POST /hackerolympics.json HTTP/1.1\r\nhost: 106.186.16.8\r\ncontent-length: 0\r\nConnection: keep-alive\r\n\r\n',
_headerSent: true,
parser: null,
res: [Circular] },
ondata: null },
connection:
{ _connecting: false,
_handle:
{ fd: 22,
writeQueueSize: 0,
owner: [Circular],
onread: [Function: onread],
reading: true },
_readableState:
{ highWaterMark: 16384,
buffer: [],
length: 0,
pipes: null,
pipesCount: 0,
flowing: false,
ended: false,
endEmitted: false,
reading: true,
calledRead: true,
sync: false,
needReadable: true,
emittedReadable: false,
readableListening: false,
objectMode: false,
defaultEncoding: 'utf8',
ranOut: false,
awaitDrain: 0,
readingMore: false,
decoder: null,
encoding: null },
readable: true,
domain: null,
_events:
{ end: [Object],
finish: [Function: onSocketFinish],
_socketEnd: [Function: onSocketEnd],
free: [Function],
close: [Object],
agentRemove: [Function],
drain: [Function: ondrain],
error: undefined,
connect: undefined },
_maxListeners: 10,
_writableState:
{ highWaterMark: 16384,
objectMode: false,
needDrain: false,
ending: false,
ended: false,
finished: false,
decodeStrings: false,
defaultEncoding: 'utf8',
length: 0,
writing: false,
sync: false,
bufferProcessing: false,
onwrite: [Function],
writecb: null,
writelen: 0,
buffer: [] },
writable: true,
allowHalfOpen: false,
onend: null,
destroyed: false,
errorEmitted: false,
bytesRead: 270,
_bytesDispatched: 101,
_pendingData: null,
_pendingEncoding: '',
parser: null,
_httpMessage:
{ domain: null,
_events: [Object],
_maxListeners: 10,
output: [],
outputEncodings: [],
writable: true,
_last: false,
chunkedEncoding: false,
shouldKeepAlive: true,
useChunkedEncodingByDefault: true,
sendDate: false,
_hasBody: true,
_trailer: '',
finished: true,
_hangupClose: false,
socket: [Circular],
connection: [Circular],
agent: [Object],
socketPath: undefined,
method: 'POST',
path: '/hackerolympics.json',
_headers: [Object],
_headerNames: [Object],
_header: 'POST /hackerolympics.json HTTP/1.1\r\nhost: 106.186.16.8\r\ncontent-length: 0\r\nConnection: keep-alive\r\n\r\n',
_headerSent: true,
parser: null,
res: [Circular] },
ondata: null },
httpVersion: '1.1',
complete: true,
headers:
{ server: 'nginx/1.1.19',
date: 'Sat, 22 Jun 2013 04:04:00 GMT',
'content-type': 'application/json;charset=utf-8',
'content-length': '53',
connection: 'keep-alive',
status: '200 OK',
'x-content-type-options': 'nosniff' },
trailers: {},
_pendings: [],
_pendingIndex: 0,
url: '',
method: null,
statusCode: 200,
client:
{ _connecting: false,
_handle:
{ fd: 22,
writeQueueSize: 0,
owner: [Circular],
onread: [Function: onread],
reading: true },
_readableState:
{ highWaterMark: 16384,
buffer: [],
length: 0,
pipes: null,
pipesCount: 0,
flowing: false,
ended: false,
endEmitted: false,
reading: true,
calledRead: true,
sync: false,
needReadable: true,
emittedReadable: false,
readableListening: false,
objectMode: false,
defaultEncoding: 'utf8',
ranOut: false,
awaitDrain: 0,
readingMore: false,
decoder: null,
encoding: null },
readable: true,
domain: null,
_events:
{ end: [Object],
finish: [Function: onSocketFinish],
_socketEnd: [Function: onSocketEnd],
free: [Function],
close: [Object],
agentRemove: [Function],
drain: [Function: ondrain],
error: undefined,
connect: undefined },
_maxListeners: 10,
_writableState:
{ highWaterMark: 16384,
objectMode: false,
needDrain: false,
ending: false,
ended: false,
finished: false,
decodeStrings: false,
defaultEncoding: 'utf8',
length: 0,
writing: false,
sync: false,
bufferProcessing: false,
onwrite: [Function],
writecb: null,
writelen: 0,
buffer: [] },
writable: true,
allowHalfOpen: false,
onend: null,
destroyed: false,
errorEmitted: false,
bytesRead: 270,
_bytesDispatched: 101,
_pendingData: null,
_pendingEncoding: '',
parser: null,
_httpMessage:
{ domain: null,
_events: [Object],
_maxListeners: 10,
output: [],
outputEncodings: [],
writable: true,
_last: false,
chunkedEncoding: false,
shouldKeepAlive: true,
useChunkedEncodingByDefault: true,
sendDate: false,
_hasBody: true,
_trailer: '',
finished: true,
_hangupClose: false,
socket: [Circular],
connection: [Circular],
agent: [Object],
socketPath: undefined,
method: 'POST',
path: '/hackerolympics.json',
_headers: [Object],
_headerNames: [Object],
_header: 'POST /hackerolympics.json HTTP/1.1\r\nhost: 106.186.16.8\r\ncontent-length: 0\r\nConnection: keep-alive\r\n\r\n',
_headerSent: true,
parser: null,
res: [Circular] },
ondata: null },
_consuming: true,
_dumped: false,
httpVersionMajor: 1,
httpVersionMinor: 1,
upgrade: false,
req:
{ domain: null,
_events:
{ response: undefined,
socket: undefined,
error: [Function],
drain: [Function] },
_maxListeners: 10,
output: [],
outputEncodings: [],
writable: true,
_last: false,
chunkedEncoding: false,
shouldKeepAlive: true,
useChunkedEncodingByDefault: true,
sendDate: false,
_hasBody: true,
_trailer: '',
finished: true,
_hangupClose: false,
socket:
{ _connecting: false,
_handle: [Object],
_readableState: [Object],
readable: true,
domain: null,
_events: [Object],
_maxListeners: 10,
_writableState: [Object],
writable: true,
allowHalfOpen: false,
onend: null,
destroyed: false,
errorEmitted: false,
bytesRead: 270,
_bytesDispatched: 101,
_pendingData: null,
_pendingEncoding: '',
parser: null,
_httpMessage: [Circular],
ondata: null },
connection:
{ _connecting: false,
_handle: [Object],
_readableState: [Object],
readable: true,
domain: null,
_events: [Object],
_maxListeners: 10,
_writableState: [Object],
writable: true,
allowHalfOpen: false,
onend: null,
destroyed: false,
errorEmitted: false,
bytesRead: 270,
_bytesDispatched: 101,
_pendingData: null,
_pendingEncoding: '',
parser: null,
_httpMessage: [Circular],
ondata: null },
agent:
{ domain: null,
_events: [Object],
_maxListeners: 10,
options: {},
requests: {},
sockets: [Object],
maxSockets: 5,
createConnection: [Function] },
socketPath: undefined,
method: 'POST',
path: '/hackerolympics.json',
_headers: { host: '106.186.16.8', 'content-length': 0 },
_headerNames: { host: 'host', 'content-length': 'content-length' },
_header: 'POST /hackerolympics.json HTTP/1.1\r\nhost: 106.186.16.8\r\ncontent-length: 0\r\nConnection: keep-alive\r\n\r\n',
_headerSent: true,
parser: null,
res: [Circular] },
pipe: [Function],
addListener: [Function],
on: [Function],
pause: [Function],
resume: [Function],
read: [Function],
request:
{ domain: null,
_events:
{ error: [Function],
complete: [Function],
pipe: [Object],
end: [Object],
data: [Function] },
_maxListeners: 10,
readable: true,
writable: true,
uri:
{ protocol: 'http:',
slashes: true,
auth: null,
host: '106.186.16.8',
port: 80,
hostname: '106.186.16.8',
hash: null,
search: null,
query: null,
pathname: '/hackerolympics.json',
path: '/hackerolympics.json',
href: 'http://106.186.16.8/hackerolympics.json' },
method: 'POST',
callback: [Function],
explicitMethod: true,
localAddress: undefined,
pool: {},
dests: [],
__isRequestRequest: true,
_callback: [Function],
_redirectsFollowed: 0,
maxRedirects: 10,
followRedirect: true,
followAllRedirects: false,
redirects: [],
headers: { 'content-length': 0 },
setHost: true,
originalCookieHeader: undefined,
_jar: undefined,
port: 80,
host: '106.186.16.8',
clientErrorHandler: [Function],
_parserErrorHandler: [Function],
path: '/hackerolympics.json',
httpModule:
{ parsers: [Object],
STATUS_CODES: [Object],
IncomingMessage: [Object],
OutgoingMessage: [Object],
ServerResponse: [Object],
Agent: [Object],
globalAgent: [Object],
ClientRequest: [Object],
request: [Function],
get: [Function],
Server: [Object],
createServer: [Function],
connectionListener: [Function: connectionListener],
Client: [Function: deprecated],
createClient: [Function: deprecated] },
agentClass: { [Function: Agent] super
: [Object], defaultMaxSockets: 5 },
agent:
{ domain: null,
_events: [Object],
_maxListeners: 10,
options: {},
requests: {},
sockets: [Object],
maxSockets: 5,
createConnection: [Function] },
_started: true,
href: 'http://106.186.16.8/hackerolympics.json',
req:
{ domain: null,
_events: [Object],
_maxListeners: 10,
output: [],
outputEncodings: [],
writable: true,
_last: false,
chunkedEncoding: false,
shouldKeepAlive: true,
useChunkedEncodingByDefault: true,
sendDate: false,
_hasBody: true,
_trailer: '',
finished: true,
_hangupClose: false,
socket: [Object],
connection: [Object],
agent: [Object],
socketPath: undefined,
method: 'POST',
path: '/hackerolympics.json',
_headers: [Object],
_headerNames: [Object],
_header: 'POST /hackerolympics.json HTTP/1.1\r\nhost: 106.186.16.8\r\ncontent-length: 0\r\nConnection: keep-alive\r\n\r\n',
_headerSent: true,
parser: null,
res: [Circular] },
ntick: true,
response: [Circular],
_destdata: true,
_ended: true,
_callbackCalled: true },
toJSON: [Function: toJSON],

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment