Skip to content

Instantly share code, notes, and snippets.

@eybisi
Last active December 16, 2022 08:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eybisi/157c76e1491ed26c2e510c4f5a49b4bb to your computer and use it in GitHub Desktop.
Save eybisi/157c76e1491ed26c2e510c4f5a49b4bb to your computer and use it in GitHub Desktop.
dga for alien sample
from datetime import datetime
import hashlib
def gen_dga_from_day(day):
# https://twitter.com/_CPResearch_/status/1603375823448317953?s=20&t=TkPpJYjVudhg2JnHbeVQFQ
"""
int i2 = 5;
int i3 = calendar.get(5);
int i4 = calendar.get(1);
if (i3 >= 10) {
if (i3 < 20 && i3 > 10) {
i2 = 15;
} else if (i3 > 20) {
i2 = 25;
}
}
"""
year_i = datetime.today().year
month_i = datetime.today().month - 1
today = day
if today > 10 and today < 20:
day_i = 15
elif today > 20:
day_i = 25
else:
day_i = 5
print(f"Current seed year={year_i},month={month_i+1},day={day_i}")
seed = f"{int(str(month_i) + str(day_i) + str(year_i))*61}"
digest = hashlib.md5(seed.encode("utf-8")).hexdigest()
return f"http://{digest}.xyz"
def gen_dga_domains():
# only edge cases
k = [10, 11, 20, 30]
for i in k:
print(gen_dga_from_day(i))
gen_dga_domains()
@stirnim
Copy link

stirnim commented Dec 15, 2022

I think it should be this

@@ -17,7 +17,7 @@
     }
     """
     year_i = datetime.today().year
-    month_i = datetime.today().month
+    month_i = datetime.today().month - 1
     today = day
     if today > 10 and today < 20:
         day_i = 15
@@ -25,8 +25,8 @@
         day_i = 25
     else:
         day_i = 5
-    print(f"Current seed year={year_i},month={month_i},day={day_i}")
-    seed = f"{(month_i+day_i+year_i)*61}"
+    print(f"Current seed year={year_i},month={month_i+1},day={day_i}")
+    seed = f"{int(str(month_i) + str(day_i) + str(year_i))*61}"
     digest = hashlib.md5(seed.encode("utf-8")).hexdigest()
     return f"http://{digest}.xyz"

@eybisi
Copy link
Author

eybisi commented Dec 16, 2022

ahh my bad you are right..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment