Python string.atol() Examples

The following are 16 code examples for showing how to use string.atol(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.

You may check out the related API usage on the sidebar.

You may also want to check out all available functions/classes of the module string , or try the search function .

Example 1
Project: darkc0de-old-stuff   Author: tuwid   File: opcodes.py    License: GNU General Public License v3.0 6 votes vote down vote up
def addr (self, mytab):
	        l = []
		for i in mytab :
	                l.append(str(hex(ord(i))))

		if(len(l) > 0) :
			l.reverse()
			var = l.pop(0)
			for i in l : 
				if(len(i) == 3) :
					if(i == "0x0") :
						i = i + "0"
		 			else :
						i = i[:2] + "0" + i[2]

				var = var + i[2:]
        
			#print "VAR %s" % var
   			addresse = string.atol(var, 16)
      		else :
			addresse = 0 

      		return (addresse) 
Example 2
Project: ironpython2   Author: IronLanguages   File: test_string.py    License: Apache License 2.0 5 votes vote down vote up
def test_atol(self):
        self.assertEqual(string.atol("  1  "), 1L)
        self.assertRaises(ValueError, string.atol, "  1x ")
        self.assertRaises(ValueError, string.atol, "  x1 ") 
Example 3
Project: BinderFilter   Author: dxwu   File: test_string.py    License: MIT License 5 votes vote down vote up
def test_atol(self):
        self.assertEqual(string.atol("  1  "), 1L)
        self.assertRaises(ValueError, string.atol, "  1x ")
        self.assertRaises(ValueError, string.atol, "  x1 ") 
Example 4
Project: oss-ftp   Author: aliyun   File: test_string.py    License: MIT License 5 votes vote down vote up
def test_atol(self):
        self.assertEqual(string.atol("  1  "), 1L)
        self.assertRaises(ValueError, string.atol, "  1x ")
        self.assertRaises(ValueError, string.atol, "  x1 ") 
Example 5
Project: gcblue   Author: gcblue   File: test_string.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_atol(self):
        self.assertEqual(string.atol("  1  "), 1L)
        self.assertRaises(ValueError, string.atol, "  1x ")
        self.assertRaises(ValueError, string.atol, "  x1 ") 
Example 6
Project: medicare-demo   Author: ofermend   File: test_string.py    License: Apache License 2.0 5 votes vote down vote up
def test_atol(self):
        self.assertEqual(string.atol("  1  "), 1L)
        self.assertRaises(ValueError, string.atol, "  1x ")
        self.assertRaises(ValueError, string.atol, "  x1 ") 
Example 7
Project: darkc0de-old-stuff   Author: tuwid   File: syscalls.py    License: GNU General Public License v3.0 5 votes vote down vote up
def checkFingerprints(self, fd) :
		syscalls_hijack = []
		end = 0
		self.getSyscalls()
		self.getOpcodes()
			
		i = fd.readline()
		liste = i.split()
		while(liste != [] and end == 0):
			if(liste[0] != '#') :
				self.syscalls_fingerprints.map_syscalls[int(liste[0])] = [string.atol(liste[1], 16), liste[3] + " " + liste[4]]
			else :
				if(len(liste) > 1) :
					if(liste[1] == "END"):
						end = -1

			i = fd.readline()
			liste = i.split()

		print "++ Checking Syscalls Fingerprints !!!"
		for i in self.lists_syscalls:
			if((self.syscalls_fingerprints.map_syscalls[i[0]][0] != self.syscalls_mem.map_syscalls[i[0]][0]) or (self.syscalls_fingerprints.map_syscalls[i[0]][1] != self.syscalls_mem.map_syscalls[i[0]][1])):
				syscalls_hijack.append([i[0], i[1]])
	
		if(syscalls_hijack != []):
			print "\t** LISTS OF SYSCALLS HIJACK !!"
			for i in syscalls_hijack:
				print "\t\t** %d\t %-15s" %(i[0], i[1])

			print "\n\t** PLEASE REINSTALL YOUR SYSTEM NOW !!!"

		else:
			print "\t** NO SYSCALLS HIJACK" 
Example 8
Project: darkc0de-old-stuff   Author: tuwid   File: networks.py    License: GNU General Public License v3.0 5 votes vote down vote up
def _iphexatodec(self, iphexa) :
		ipdec=""

		for i in range(0, 8, 2) :
			ipdec = "%d" % string.atol(iphexa[i:i+2], 16) + "." + ipdec
		
		if(iphexa[9:] == "0000") :
			ipdec = ipdec[:-1] + ":" + "*"
		else :
			ipdec = ipdec[:-1] + ":" + "%d" % string.atol(iphexa[9:], 16)
		
		
		return ipdec 
Example 9
Project: darkc0de-old-stuff   Author: tuwid   File: memory.py    License: GNU General Public License v3.0 5 votes vote down vote up
def _getBase(self) :
		base = ulibzeppoo.idtr()
		return string.atol(base, 16) 
Example 10
Project: pentestly   Author: praetorian-code   File: netblock.py    License: GNU General Public License v3.0 5 votes vote down vote up
def strtocidr(ips):
	"""returns CIDR start + length from string"""
	rng = 32
	pos = string.find(ips, '/')
	if not pos == -1:
		rng = string.atoi(ips[pos+1:])
		ips = ips[:pos]
	if string.find(ips, '.') == -1:
		ip = string.atol(ips)
	else:
		ip = strtoip(ips)
	if rng < 0 or rng > 32:
		raise ValueError, "CIDR length out of range"
	return (ip, rng) 
Example 11
Project: CTFCrackTools-V2   Author: Acmesec   File: test_string.py    License: GNU General Public License v3.0 5 votes vote down vote up
def test_atol(self):
        self.assertEqual(string.atol("  1  "), 1L)
        self.assertRaises(ValueError, string.atol, "  1x ")
        self.assertRaises(ValueError, string.atol, "  x1 ") 
Example 12
Project: recon-ng   Author: methos2016   File: netblock.py    License: GNU General Public License v3.0 5 votes vote down vote up
def strtocidr(ips):
	"""returns CIDR start + length from string"""
	rng = 32
	pos = string.find(ips, '/')
	if not pos == -1:
		rng = string.atoi(ips[pos+1:])
		ips = ips[:pos]
	if string.find(ips, '.') == -1:
		ip = string.atol(ips)
	else:
		ip = strtoip(ips)
	if rng < 0 or rng > 32:
		raise ValueError, "CIDR length out of range"
	return (ip, rng) 
Example 13
Project: EasY_HaCk   Author: sabri-zaki   File: netblock.py    License: Apache License 2.0 5 votes vote down vote up
def strtocidr(ips):
	"""returns CIDR start + length from string"""
	rng = 32
	pos = string.find(ips, '/')
	if not pos == -1:
		rng = string.atoi(ips[pos+1:])
		ips = ips[:pos]
	if string.find(ips, '.') == -1:
		ip = string.atol(ips)
	else:
		ip = strtoip(ips)
	if rng < 0 or rng > 32:
		raise ValueError, "CIDR length out of range"
	return (ip, rng) 
Example 14
Project: lpts   Author: Scemoon   File: magic.py    License: GNU General Public License v2.0 5 votes vote down vote up
def _str_to_num(n):
    """
    Convert a hex or octal string to a decimal number.

    :param n: Hex or octal string to be converted.
    :return: Resulting decimal number.
    """
    val = 0
    col = long(1)
    if n[:1] == 'x':
        n = '0' + n
    if n[:2] == '0x':
        # hex
        n = string.lower(n[2:])
        while len(n) > 0:
            l = n[len(n) - 1]
            val = val + string.hexdigits.index(l) * col
            col = col * 16
            n = n[:len(n) - 1]
    elif n[0] == '\\':
        # octal
        n = n[1:]
        while len(n) > 0:
            l = n[len(n) - 1]
            if ord(l) < 48 or ord(l) > 57:
                break
            val = val + int(l) * col
            col = col * 8
            n = n[:len(n) - 1]
    else:
        val = string.atol(n)
    return val 
Example 15
Project: CTFCrackTools   Author: Acmesec   File: test_string.py    License: GNU General Public License v3.0 5 votes vote down vote up
def test_atol(self):
        self.assertEqual(string.atol("  1  "), 1L)
        self.assertRaises(ValueError, string.atol, "  1x ")
        self.assertRaises(ValueError, string.atol, "  x1 ") 
Example 16
Project: darkc0de-old-stuff   Author: tuwid   File: zeppoo.py    License: GNU General Public License v3.0 4 votes vote down vote up
def main(options, arguments):
	#print 'options %s' % options
	#print 'arguments %s' % arguments
	if(options.device != None) :
		if(options.device == '/dev/mem') :
			mmemory = Mem()
		elif(options.device == '/dev/kmem') :
			mmemory = Kmem()
		else:
			usage()
	else :
		mmemory = Kmem()

	if(options.usemmap == None):
		options.usemmap = 0

	if(options.view != None):
		if(options.view == 'tasks'):
			ttasks = GVTasks(mmemory, options.usemmap)
			ttasks.viewTasks()
		elif(options.view == 'syscalls'):
			mysyscalls = GVSyscalls(mmemory, options.usemmap)
			mysyscalls.viewSyscalls()
		elif(options.view == 'networks'):
			nnetworks = GVNetworks(mmemory, options.usemmap)
			nnetworks.viewNetworks()
			
	elif(options.check != None):
		if(options.check == 'tasks'):
			ttasks = GVTasks(mmemory, options.usemmap)
			ttasks.checkViewTasks()
		elif(options.check == 'networks'):
			nnetworks = GVNetworks(mmemory, options.usemmap)
			nnetworks.checkViewNetworks()
			
	elif(options.fingerprints != None):
		ffingerprints = Fingerprints(mmemory)
		if(options.fingerprints[1] == 'create'):
			ffingerprints.doFingerprints(options.fingerprints[0])
		elif(options.fingerprints[1] == 'check'):
			ffingerprints.checkFingerprints(options.fingerprints[0])
			
	elif(options.bump != None):
		mmemory.open("r", options.usemmap)
		mmemory.dump(string.atol(options.bump[0], 16), int(options.bump[1]), options.bump[2])
		mmemory.close()
	
	else:
		usage()