MCPcopy Index your code
hub / github.com/sqlmapproject/sqlmap / parseTargetDirect

Function parseTargetDirect

lib/core/common.py:1587–1706  ·  view source on GitHub ↗

Parse target dbms and set some attributes into the configuration singleton >>> pushValue(conf.direct) >>> conf.direct = "mysql://root:testpass@127.0.0.1:3306/testdb" >>> parseTargetDirect() >>> conf.dbmsDb 'testdb' >>> conf.dbmsPass 'testpass' >>> conf.direct =

()

Source from the content-addressed store, hash-verified

1585 return hasattr(sys, "frozen")
1586
1587def parseTargetDirect():
1588 """
1589 Parse target dbms and set some attributes into the configuration singleton
1590
1591 >>> pushValue(conf.direct)
1592 >>> conf.direct = "mysql://root:testpass@127.0.0.1:3306/testdb"
1593 >>> parseTargetDirect()
1594 >>> conf.dbmsDb
1595 'testdb'
1596 >>> conf.dbmsPass
1597 'testpass'
1598 >>> conf.direct = "mysql://user:'P@ssw0rd'@127.0.0.1:3306/test"
1599 >>> parseTargetDirect()
1600 >>> conf.dbmsPass
1601 'P@ssw0rd'
1602 >>> conf.hostname
1603 '127.0.0.1'
1604 >>> conf.direct = popValue()
1605 """
1606
1607 if not conf.direct:
1608 return
1609
1610 details = None
1611 remote = False
1612
1613 for dbms in SUPPORTED_DBMS:
1614 details = re.search(r"^(?P<dbms>%s)://(?P<credentials>(?P<user>.*?)\:(?P<pass>.*)\@)?(?P<remote>(?P<hostname>[\w.-]+?)\:(?P<port>[\d]+)\/)?(?P<db>[\w\d\ \:\.\_~\-\/\\]*)$" % dbms, conf.direct, re.I)
1615
1616 if details:
1617 conf.dbms = details.group("dbms")
1618
1619 if details.group("credentials"):
1620 conf.dbmsUser = details.group("user").strip("'\"")
1621 conf.dbmsPass = details.group("pass").strip("'\"")
1622 else:
1623 if conf.dbmsCred:
1624 conf.dbmsUser, conf.dbmsPass = conf.dbmsCred.split(':')
1625 else:
1626 conf.dbmsUser = ""
1627 conf.dbmsPass = ""
1628
1629 if not conf.dbmsPass:
1630 conf.dbmsPass = None
1631
1632 if details.group("remote"):
1633 remote = True
1634 conf.hostname = details.group("hostname").strip()
1635 conf.port = int(details.group("port"))
1636 else:
1637 conf.hostname = "localhost"
1638 conf.port = 0
1639
1640 conf.dbmsDb = details.group("db").strip() if details.group("db") is not None else None
1641 conf.parameters[None] = "direct connection"
1642
1643 break
1644

Callers 1

initFunction · 0.90

Calls 4

itemsMethod · 0.80
searchMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…