Skip to content

Commit

Permalink
Rewrite Beta 1.1
Browse files Browse the repository at this point in the history
- New txt output format
- Fixed bugs relating to file names
  • Loading branch information
BirdsAreFlyingCameras committed May 15, 2024
1 parent abc2db4 commit 5a0cf2c
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 135 deletions.
Binary file added Gifs/Demo-Gif.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@

## About

### Version Number: Rewrite Beta 1.0
### Version Number: Rewrite Beta 1.1

HistorianDNS is a script retrieves parses displays historical DNS records from dnshistory.com with the option of saving the results in a .txt format.

The last main branch release was beta 0.2.2 released on 11/02/2023 since then a full rewrite happened starting on 03/30/2024 with rewrite beta 1.0 being released on 05/06/2024.

### Rewrite Beta 1.1 Updates

- New txt output format
- Fixed bugs relating to file names

## Installation

Expand Down Expand Up @@ -35,7 +39,7 @@ To run the script do:

## Usage Example

![Usage.gif](Gifs/Usage.gif)
![Demo-Gif.gif](Gifs/Demo-Gif.gif)


## Todo
Expand Down
167 changes: 34 additions & 133 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,10 +277,7 @@ def Filter(self):

Record = Record.replace('<', "").replace('>', '')

if IterCount == 0 or IterCount == 1: # The first SOA record doesn't have the RName field
NewLineList = ["MName:", "Serial:", "Refresh:", "Retry:", "Expire:"]
else:
NewLineList = ["MName:", "RName:", "Serial:", "Refresh:", "Retry:", "Expire:"]
NewLineList = ["MName:", "Serial:", "Refresh:", "Retry:", "Expire:"]

for NewLine in NewLineList:
NewLineIndex = Record.index(NewLine)
Expand Down Expand Up @@ -453,149 +450,51 @@ def SaveResults(self):

def MakeTXT(SaveFileName:str):

BannerNameForTXT = SaveFileName.replace(".txt", "")
RecordTypeList = [
"SOA",
"NS",
"MX",
"A",
"AAAA",
"CNAME",
"PTR",
"TXT"
]

with open(SaveFileName, 'x', encoding='utf-8') as f:

f.write(f"┣━━━━━━━━━━ HistorianDNS Results for {BannerNameForTXT} ━━━━━━━━━━┫")

f.write('\n')
f.write('\n')
f.write('\n')

f.write('━━━━━┫ SOA Records ┣━━━━━')

f.write('\n')
f.write('\n')

if self.RecordsFiltered.get('SOA') != 0:
for SOA in self.RecordsFiltered.get('SOA'):
if SOA != " ":
f.write(SOA)
f.write('\n')
else:
f.write("No SOA Records Found")


f.write('\n')
f.write('\n')

f.write('━━━━━┫ NS Records ┣━━━━━')
BannerNameForTXT = self.URL

f.write('\n')
f.write('\n')
TableForTXT = Table()

if self.RecordsFiltered.get('NS') != 0:
for NS in self.RecordsFiltered.get('NS'):
if NS != " ":
f.write(SOA)
f.write('\n')
TableForTXT.show_header = False

else:
f.write("No NS Records Found")

f.write('\n')
f.write('\n')

f.write('━━━━━┫ A Records ┣━━━━━')

f.write('\n')
f.write('\n')

if self.RecordsFiltered.get('A') != 0:
for A in self.RecordsFiltered.get('A'):
if A != " ":
f.write(A)
f.write('\n')
else:
f.write("No A Records Found")

f.write('\n')
f.write('\n')

f.write('━━━━━┫ AAAA Records ┣━━━━━')
TableForTXT.add_section()

f.write('\n')
f.write('\n')
TableForTXT.add_row(Align(f"Historian DNS Results For {BannerNameForTXT}", align="center"))

if self.RecordsFiltered.get('AAAA') != 0:
for AAAA in self.RecordsFiltered.get('AAAA'):
if AAAA != " ":
f.write(AAAA)
f.write('\n')

else:
f.write("No AAAA Records Found")
TableForTXT.add_section()

f.write('\n')
f.write('\n')
for RecordType in RecordTypeList:

f.write('━━━━━┫ MX Records ┣━━━━━')
if RecordType != "SOA":
TableForTXT.add_section()

f.write('\n')
f.write('\n')
TableForTXT.add_row(Align(f'{RecordType} Records', align="center"))

if self.RecordsFiltered.get('MX') != 0:
for MX in self.RecordsFiltered.get('MX'):
if MX != " ":
f.write(MX)
f.write('\n')
TableForTXT.add_section()

if RecordType != "NS":
for Record in self.RecordsFiltered[RecordType]:
TableForTXT.add_row(f"{Record}")
else:
f.write("No MX Records Found")
for RecordsList in self.RecordsFiltered[RecordType]:
for Record in RecordsList:
TableForTXT.add_row(f"{Record}")

f.write('\n')
f.write('\n')

f.write('━━━━━┫ CNAME Records ┣━━━━━')

f.write('\n')
f.write('\n')

if self.RecordsFiltered.get('CNAME') != 0:
for CNAME in self.RecordsFiltered.get('CNAME'):
if CNAME != " ":
f.write(CNAME)
f.write('\n')

else:
f.write("No CNAME Records Found")

f.write('\n')
f.write('\n')

f.write('━━━━━┫ PTR Records ┣━━━━━')

f.write('\n')
f.write('\n')

if self.RecordsFiltered.get('PTR') != 0:
for PTR in self.RecordsFiltered.get('PTR'):
if PTR != " ":
f.write(PTR)
f.write('\n')

else:
f.write("No PTR Records Found")

f.write('\n')
f.write('\n')

f.write('━━━━━┫ TXT Records ┣━━━━━')

f.write('\n')
f.write('\n')

if self.RecordsFiltered.get('TXT') != 0:
for TXT in self.RecordsFiltered.get('TXT'):
if TXT != " ":
f.write(TXT)
f.write('\n')

else:
f.write("No TXT Records Found")
from rich import print as rprint
with open(SaveFileName, 'x', encoding='utf-8') as f:
rprint(TableForTXT, file=f)

f.write('\n')

if self.UserOS == "Linux" or self.UserOS == "MacOS" or self.UserOS == "Unknown":
print('\n')
Expand All @@ -607,8 +506,10 @@ def MakeTXT(SaveFileName:str):
print(f"{Stamps.Stamp.Output} Saved Results to {os.path.dirname(os.path.abspath(__file__))}\\{SaveFileName}")
print('\n')
print(f"{Stamps.Stamp.Info} Exiting")


def SaveFileNameHandling():
SaveFileName = f"HistorianDNS-{self.URL}.txt"
SaveFileName = f"HistorianDNS-{str(self.URL)[:str(self.URL).rindex('.')]}.txt"

if os.path.exists(SaveFileName):
print("\n")
Expand Down

0 comments on commit 5a0cf2c

Please sign in to comment.