Skip to content

Commit 6a71629

Browse files
committed
Converted from DOS format (\n\r to \n only)
1 parent 7dcfcca commit 6a71629

15 files changed

Lines changed: 1135 additions & 1135 deletions

extra/pagerank/pagerank.py

Lines changed: 75 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,75 @@
1-
#!/usr/bin/env python
2-
#
3-
# Script for getting Google Page Rank of page
4-
# Google Toolbar 3.0.x/4.0.x Pagerank Checksum Algorithm
5-
#
6-
# original from http://pagerank.gamesaga.net/
7-
# this version was adapted from http://www.djangosnippets.org/snippets/221/
8-
# by Corey Goldberg - 2010
9-
#
10-
# Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
11-
12-
import urllib
13-
14-
def get_pagerank(url):
15-
hsh = check_hash(hash_url(url))
16-
gurl = 'http://www.google.com/search?client=navclient-auto&features=Rank:&q=info:%s&ch=%s' % (urllib.quote(url), hsh)
17-
try:
18-
f = urllib.urlopen(gurl)
19-
rank = f.read().strip()[9:]
20-
except Exception:
21-
rank = 'N/A'
22-
if rank == '':
23-
rank = '0'
24-
return rank
25-
26-
def int_str(string, integer, factor):
27-
for i in range(len(string)) :
28-
integer *= factor
29-
integer &= 0xFFFFFFFF
30-
integer += ord(string[i])
31-
return integer
32-
33-
def hash_url(string):
34-
c1 = int_str(string, 0x1505, 0x21)
35-
c2 = int_str(string, 0, 0x1003F)
36-
37-
c1 >>= 2
38-
c1 = ((c1 >> 4) & 0x3FFFFC0) | (c1 & 0x3F)
39-
c1 = ((c1 >> 4) & 0x3FFC00) | (c1 & 0x3FF)
40-
c1 = ((c1 >> 4) & 0x3C000) | (c1 & 0x3FFF)
41-
42-
t1 = (c1 & 0x3C0) << 4
43-
t1 |= c1 & 0x3C
44-
t1 = (t1 << 2) | (c2 & 0xF0F)
45-
46-
t2 = (c1 & 0xFFFFC000) << 4
47-
t2 |= c1 & 0x3C00
48-
t2 = (t2 << 0xA) | (c2 & 0xF0F0000)
49-
50-
return (t1 | t2)
51-
52-
def check_hash(hash_int):
53-
hash_str = '%u' % (hash_int)
54-
flag = 0
55-
check_byte = 0
56-
57-
i = len(hash_str) - 1
58-
while i >= 0:
59-
byte = int(hash_str[i])
60-
if 1 == (flag % 2):
61-
byte *= 2;
62-
byte = byte / 10 + byte % 10
63-
check_byte += byte
64-
flag += 1
65-
i -= 1
66-
67-
check_byte %= 10
68-
if 0 != check_byte:
69-
check_byte = 10 - check_byte
70-
if 1 == flag % 2:
71-
if 1 == check_byte % 2:
72-
check_byte += 9
73-
check_byte >>= 1
74-
75-
return '7' + str(check_byte) + hash_str
1+
#!/usr/bin/env python
2+
#
3+
# Script for getting Google Page Rank of page
4+
# Google Toolbar 3.0.x/4.0.x Pagerank Checksum Algorithm
5+
#
6+
# original from http://pagerank.gamesaga.net/
7+
# this version was adapted from http://www.djangosnippets.org/snippets/221/
8+
# by Corey Goldberg - 2010
9+
#
10+
# Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
11+
12+
import urllib
13+
14+
def get_pagerank(url):
15+
hsh = check_hash(hash_url(url))
16+
gurl = 'http://www.google.com/search?client=navclient-auto&features=Rank:&q=info:%s&ch=%s' % (urllib.quote(url), hsh)
17+
try:
18+
f = urllib.urlopen(gurl)
19+
rank = f.read().strip()[9:]
20+
except Exception:
21+
rank = 'N/A'
22+
if rank == '':
23+
rank = '0'
24+
return rank
25+
26+
def int_str(string, integer, factor):
27+
for i in range(len(string)) :
28+
integer *= factor
29+
integer &= 0xFFFFFFFF
30+
integer += ord(string[i])
31+
return integer
32+
33+
def hash_url(string):
34+
c1 = int_str(string, 0x1505, 0x21)
35+
c2 = int_str(string, 0, 0x1003F)
36+
37+
c1 >>= 2
38+
c1 = ((c1 >> 4) & 0x3FFFFC0) | (c1 & 0x3F)
39+
c1 = ((c1 >> 4) & 0x3FFC00) | (c1 & 0x3FF)
40+
c1 = ((c1 >> 4) & 0x3C000) | (c1 & 0x3FFF)
41+
42+
t1 = (c1 & 0x3C0) << 4
43+
t1 |= c1 & 0x3C
44+
t1 = (t1 << 2) | (c2 & 0xF0F)
45+
46+
t2 = (c1 & 0xFFFFC000) << 4
47+
t2 |= c1 & 0x3C00
48+
t2 = (t2 << 0xA) | (c2 & 0xF0F0000)
49+
50+
return (t1 | t2)
51+
52+
def check_hash(hash_int):
53+
hash_str = '%u' % (hash_int)
54+
flag = 0
55+
check_byte = 0
56+
57+
i = len(hash_str) - 1
58+
while i >= 0:
59+
byte = int(hash_str[i])
60+
if 1 == (flag % 2):
61+
byte *= 2;
62+
byte = byte / 10 + byte % 10
63+
check_byte += byte
64+
flag += 1
65+
i -= 1
66+
67+
check_byte %= 10
68+
if 0 != check_byte:
69+
check_byte = 10 - check_byte
70+
if 1 == flag % 2:
71+
if 1 == check_byte % 2:
72+
check_byte += 9
73+
check_byte >>= 1
74+
75+
return '7' + str(check_byte) + hash_str

lib/core/replication.py

Lines changed: 102 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1,102 +1,102 @@
1-
#!/usr/bin/env python
2-
3-
"""
4-
$Id$
5-
6-
Copyright (c) 2006-2010 sqlmap developers (http://sqlmap.sourceforge.net/)
7-
See the file 'doc/COPYING' for copying permission
8-
"""
9-
10-
from lib.core.exception import sqlmapMissingDependence
11-
from lib.core.exception import sqlmapValueException
12-
13-
class Replication:
14-
"""
15-
This class holds all methods/classes used for database
16-
replication purposes.
17-
"""
18-
19-
def __init__(self, dbpath):
20-
try:
21-
import sqlite3
22-
except ImportError, _:
23-
errMsg = "missing module 'sqlite3' needed by --replicate switch"
24-
raise sqlmapMissingDependence, errMsg
25-
26-
self.dbpath = dbpath
27-
self.connection = sqlite3.connect(dbpath)
28-
self.connection.isolation_level = None
29-
self.cursor = self.connection.cursor()
30-
31-
class DataType:
32-
"""
33-
Using this class we define auxiliary objects
34-
used for representing sqlite data types.
35-
"""
36-
37-
def __init__(self, name):
38-
self.name = name
39-
40-
def __str__(self):
41-
return self.name
42-
43-
def __repr__(self):
44-
return "<DataType: %s>" % self
45-
46-
class Table:
47-
"""
48-
This class defines methods used to manipulate table objects.
49-
"""
50-
51-
def __init__(self, parent, name, columns=None, create=True, typeless=False):
52-
self.parent = parent
53-
self.name = name
54-
self.columns = columns
55-
if create:
56-
self.parent.cursor.execute('DROP TABLE IF EXISTS %s' % self.name)
57-
if not typeless:
58-
self.parent.cursor.execute('CREATE TABLE %s (%s)' % (self.name, ','.join('%s %s' % (colname, coltype) for colname, coltype in self.columns)))
59-
else:
60-
self.parent.cursor.execute('CREATE TABLE %s (%s)' % (self.name, ','.join(colname for colname in self.columns)))
61-
62-
def insert(self, values):
63-
"""
64-
This function is used for inserting row(s) into current table.
65-
"""
66-
if len(values) == len(self.columns):
67-
self.parent.cursor.execute('INSERT INTO %s VALUES (%s)' % (self.name, ','.join(['?']*len(values))), values)
68-
else:
69-
errMsg = "wrong number of columns used in replicating insert"
70-
raise sqlmapValueException, errMsg
71-
72-
def select(self, condition=None):
73-
"""
74-
This function is used for selecting row(s) from current table.
75-
"""
76-
stmt = 'SELECT * FROM %s' % self.name
77-
if condition:
78-
stmt += 'WHERE %s' % condition
79-
return self.parent.cursor.execute(stmt)
80-
81-
def createTable(self, tblname, columns=None, typeless=False):
82-
"""
83-
This function creates Table instance with current connection settings.
84-
"""
85-
return Replication.Table(parent=self, name=tblname, columns=columns, typeless=typeless)
86-
87-
def dropTable(self, tblname):
88-
"""
89-
This function drops table with given name using current connection.
90-
"""
91-
self.cursor.execute('DROP TABLE IF EXISTS %s' % tblname)
92-
93-
def __del__(self):
94-
self.cursor.close()
95-
self.connection.close()
96-
97-
# sqlite data types
98-
NULL = DataType('NULL')
99-
INTEGER = DataType('INTEGER')
100-
REAL = DataType('REAL')
101-
TEXT = DataType('TEXT')
102-
BLOB = DataType('BLOB')
1+
#!/usr/bin/env python
2+
3+
"""
4+
$Id$
5+
6+
Copyright (c) 2006-2010 sqlmap developers (http://sqlmap.sourceforge.net/)
7+
See the file 'doc/COPYING' for copying permission
8+
"""
9+
10+
from lib.core.exception import sqlmapMissingDependence
11+
from lib.core.exception import sqlmapValueException
12+
13+
class Replication:
14+
"""
15+
This class holds all methods/classes used for database
16+
replication purposes.
17+
"""
18+
19+
def __init__(self, dbpath):
20+
try:
21+
import sqlite3
22+
except ImportError, _:
23+
errMsg = "missing module 'sqlite3' needed by --replicate switch"
24+
raise sqlmapMissingDependence, errMsg
25+
26+
self.dbpath = dbpath
27+
self.connection = sqlite3.connect(dbpath)
28+
self.connection.isolation_level = None
29+
self.cursor = self.connection.cursor()
30+
31+
class DataType:
32+
"""
33+
Using this class we define auxiliary objects
34+
used for representing sqlite data types.
35+
"""
36+
37+
def __init__(self, name):
38+
self.name = name
39+
40+
def __str__(self):
41+
return self.name
42+
43+
def __repr__(self):
44+
return "<DataType: %s>" % self
45+
46+
class Table:
47+
"""
48+
This class defines methods used to manipulate table objects.
49+
"""
50+
51+
def __init__(self, parent, name, columns=None, create=True, typeless=False):
52+
self.parent = parent
53+
self.name = name
54+
self.columns = columns
55+
if create:
56+
self.parent.cursor.execute('DROP TABLE IF EXISTS %s' % self.name)
57+
if not typeless:
58+
self.parent.cursor.execute('CREATE TABLE %s (%s)' % (self.name, ','.join('%s %s' % (colname, coltype) for colname, coltype in self.columns)))
59+
else:
60+
self.parent.cursor.execute('CREATE TABLE %s (%s)' % (self.name, ','.join(colname for colname in self.columns)))
61+
62+
def insert(self, values):
63+
"""
64+
This function is used for inserting row(s) into current table.
65+
"""
66+
if len(values) == len(self.columns):
67+
self.parent.cursor.execute('INSERT INTO %s VALUES (%s)' % (self.name, ','.join(['?']*len(values))), values)
68+
else:
69+
errMsg = "wrong number of columns used in replicating insert"
70+
raise sqlmapValueException, errMsg
71+
72+
def select(self, condition=None):
73+
"""
74+
This function is used for selecting row(s) from current table.
75+
"""
76+
stmt = 'SELECT * FROM %s' % self.name
77+
if condition:
78+
stmt += 'WHERE %s' % condition
79+
return self.parent.cursor.execute(stmt)
80+
81+
def createTable(self, tblname, columns=None, typeless=False):
82+
"""
83+
This function creates Table instance with current connection settings.
84+
"""
85+
return Replication.Table(parent=self, name=tblname, columns=columns, typeless=typeless)
86+
87+
def dropTable(self, tblname):
88+
"""
89+
This function drops table with given name using current connection.
90+
"""
91+
self.cursor.execute('DROP TABLE IF EXISTS %s' % tblname)
92+
93+
def __del__(self):
94+
self.cursor.close()
95+
self.connection.close()
96+
97+
# sqlite data types
98+
NULL = DataType('NULL')
99+
INTEGER = DataType('INTEGER')
100+
REAL = DataType('REAL')
101+
TEXT = DataType('TEXT')
102+
BLOB = DataType('BLOB')

0 commit comments

Comments
 (0)