Skip to content

Commit

Permalink
Update configuration file
Browse files Browse the repository at this point in the history
  • Loading branch information
jorritolthuis committed Mar 23, 2018
1 parent fc74f61 commit 04fc0fe
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 32 deletions.
6 changes: 5 additions & 1 deletion AdBleed.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@
DnsQueryTimeout = 1
# IP of local DNS server to test
;SpecialDNS = 1.1.1.1 # Might be superfluous due to /etc/resolv.conf
# Minimum percentage of hosts to result in the same IP to classify DNS server as Pi-hole
SimilarResp = 75
# Number of hosts to randomly test at the DNS server
NumberOfHosts = 50

[Poisoning]
# Type of DNS poisoning to execute
PoisonType = ads # Replace the IPs of requests that Pi-hole says are ads
PoisonType = ads
;PoisonType = complete # Replace every DNS request

# Which IP should be substituted
Expand Down
77 changes: 46 additions & 31 deletions src/configuration.py
Original file line number Diff line number Diff line change
@@ -1,46 +1,61 @@
import configparser
import os

class Configuration:
config
path
config = None
path = None

dnsQueryTimeout = ("Discovery", "DnsQueryTimeout")
similarResponses = ("Discovery", "SimilarResp")
noOfHosts = ("Discovery", "NumberOfHosts")
poisonType = ("Poisoning", "PoisonType")
replaceIP = ("Poisoning", "ReplaceIP")

def __init__():
path = os.path.dirname(__file__) + "../AdBleed.conf"
config = configparser.ConfigParser()
config.read(path)

def set(section, variable, value):
config.set(section, variable, value)
with open(path, "wb") as file:
config.write(file)

def get(section, variable):
return config.get(section, variable)
def __init__(self):
self.path = os.path.dirname(__file__) + "/../AdBleed.conf"
self.config = configparser.ConfigParser()
self.config.read(self.path)

def setConf(self, section, variable, value):
self.config.set(section, variable, value)
with open(self.path, "wb") as file:
self.config.write(file)

def getConf(self, section, variable):
return self.config.get(section, variable)

# --------------------
# |------------------|
# | Specific get/set |
# --------------------
def setDNSQueryTimeout(value):
set(dnsQueryTimeout[0], dnsQueryTimeout[1], value)

def getDNSQueryTimeout():
return get(dnsQueryTimeout[0], dnsQueryTimeout[1])
# |------------------|
def setDNSQueryTimeout(self, value):
self.setConf(self.dnsQueryTimeout[0], self.dnsQueryTimeout[1], str.encode(value))

def setPoisonType(value):
set(poisonType[0], poisonType[1], value)

def getPoisonType():
return get(poisonType[0], poisonType[1])
def getDNSQueryTimeout(self):
return int(self.getConf(self.dnsQueryTimeout[0], self.dnsQueryTimeout[1]))

def setPoisonType(self, value):
self.setConf(self.poisonType[0], self.poisonType[1], str.encode(value))

def getPoisonType(self):
return self.getConf(self.poisonType[0], self.poisonType[1])

def setReplaceIP(self, value):
sel.fsetConf(self.replaceIP[0], self.replaceIP[1], str.encode(value))

def getReplaceIP(self):
return self.getConf(self.replaceIP[0], self.replaceIP[1])

def setReplaceIP(value):
set(replaceIP[0], replaceIP[1], value)
def setSimilarResponses(self, value):
self.setConf(self.similarResponses[0], self.similarResponses[1], str.encode(value))

def getReplaceIP():
return get(replaceIP[0], replaceIP[1])
def getSimilarResponses(self):
return int(self.getConf(self.similarResponses[0], self.similarResponses[1]))

def setNumberOfHosts(self, value):
self.setConf(self.noOfHosts[0], self.noOfHosts[1], str.encode(value))

def getNumberOfHosts(self):
return int(self.getConf(self.noOfHosts[0], self.noOfHosts[1]))

pass

0 comments on commit 04fc0fe

Please sign in to comment.