Friday, January 8, 2016

Password Generator

I built a small program tonight to better my understanding of how strings concatenate from multiple sources. I decided a simple password generator was the way to approach this. Everything I have done before has been in Python 2.x. I have decided as of today I am making the leap into Python 3.x.

I have included my code below. Hopefully I have cleaned it up enough. When trying to learn concepts I tend to write a lot of tests in-line, run, then clean up. This isn't the best way.

I first start by creating my available characters in strings. I realize you could just put this all in one string, or array, but this was not the point of what I wanted to learn.

I then built the only user interaction, which asks how long of a password you need.

After this we build our primary random string. We first add a random number (somewhere between 10 and 1000) of lower case letters, then capital letters, followed by available symbols, and finally numbers.

This should give us a string of between 40 and 4000. From there we can use our PRNG included within python to pull a number of random values from this string by the index number within the string. Then we iterate and return the number of values needed for our password.

*Note* This is not a secure password vault/generator/etc *note*

This password is then printed for your viewing pleasure, it is also placed into your computer's clipboard so you can use it where needed.

It was a fun quick project which allowed me to learn some fun concepts. For example if I were to use

 randStr = randStr.join([number[randomIndex((number.__len__() -1))] for i in range(randomGenerator())])

instead of

 randStr = randStr + ''.join([number[randomIndex((number.__len__() -1))] for i in range(randomGenerator())])

Then it produced more numbers than wanted (exponentially more). This caused even this simple program to take up 100mb of ram. I also would not get a good sample of all 4 categories for the password as a result. It was often building passwords with 1 cap in it and the rest lower case.

The other big win for me from this project was the join statements themselves. I found another blog explaining how to properly concatenate strings in python. Initially I dove into this with no research and just started writing code (this seems to help me wind down as well). Though lack of planning beforehand does not always make for even decent code...

Initially I was doing the below to build and join my random string

def addStr(randomLen):
value = ''
for num in range(randomLen):
value += randomLet[randomIndex]
return value


But this post:
https://waymoot.org/home/python_string/
showed me how to improve my efficiency greatly

def addStr(randomLen):
return ''.join([randomLet[randomIndex] for i in range(randomLen)])

This allowed me to go from about 3k concatenations per second, clear up to 119k. While this honestly doesn't matter for this program, it is something to tuck away for later.

Next, after all my experience with BSAFE I think, I will look at how to write secure numbers in Python (build a PRNG that will pull data from random or urandom. But also that will keep it secured and clear everything as it completes.

Would be interesting to see what libs are out there to do so and a ton of fun to try and write a few things with the standard libs only. I have always enjoyed Python, but the more I use it, the more I love Python so much more than Java or C/C++.

Enjoy!

Code again

It has been a while since I have updated this. I received the last of the parts for my CoreXY/H-bot designed 3d printer. I should be putting that together over the next 2 weeks. I'll document this as best as I can.
Tonight I came home tired, so I decided to write a small python program just to exercise and to help me learn Python 3.x. I will put up another post specifically about this.

Monday, December 28, 2015

One of my favorite python books has a Udemy course attached to it. Until the end of the year it is free!!! Please go sign up and you can go over the course as you have time, (you do not need to complete the course before the end of the year.

https://www.udemy.com/automate/?couponCode=RESOLVE_TO_CODE_2016

The book is released under creative commons

https://automatetheboringstuff.com/

Please pick this up if you have any interest in coding at all. Python is one of the best languages to learn a programming foundation, and you will continue using it through your whole career as well.

Friday, November 27, 2015

3D printer beginings

Ah today I started to put together what I want in a 3d printer. My goals for this project are as follows.
  1. 100% modular design. I want to be able to extend the bed, extend the height, change parts, at will. I don't want to be locked into anything if I can help it.
  2. 1 Print head for now, but I need to be able to add a 2nd at some point in the future.
  3. Ball screws for the Z axis (nice and smooth movement)
  4. Larger format than most printers I've seen. Looking to get at least 12”x12”x12” total print area. The printer I'm looking at looks more like I will be about 18”x18”x21”,
  5. Other than that just fun and design. I am going to start with a basic design and I will go from there.
  6. I will be using the plans from http://openbuilds.com/builds/c-bot.1146/ as my starting point
  7. I ordered 10500mm of 2020 aluminum today. That will be used to build my frame and the x/y gantry.

Saturday, August 29, 2015

Geeky week

It's been a while since my last post. Been traveling for work and it has been difficult to make time to write. Today though I picked up a new Raspberry Pi II B and have decided that I want to make it into the ultimate emulator box. I'm sure my wife is tired of all my old gaming systems sitting out. I'm going to set them all up on my Raspberry Pi.
The biggest things I feel I need are the following
1. Portable - When I travel I would like to be able to take it with minimal weight added to my luggage.
2. Wireless control - After this is setup I will need to make sure I can control it through wireless, it is too much trouble to have wires strewn around my hotel room.
3. Basic games - I really only care about having Zelda, Mario, Final Fantasy, and arcade games. I own most of these so I need to look at how I can license those I do not own. I have every Final Fantasy and Zelda game, need to pick up super Mario world as that is the best super Mario game. Also Super Mario RPG as well.
4. I need to figure out N64 controls. The N64 controller is out of the question as it is the time Nintendo forgot that children do not have 3 arms. On a plus note during the apocalypse the N64 will be ideal after the fallout.
5. Battery Powered - This is less important, I think I have battery packs from my pineapple that should work fine for this.
6. Wireless - Taken care of have my wireless cards I use for kali linux that I carry with me anyway. This gives me access to my high DB antenna.
7. Optional - Would be nice to have a small display, at least 5" preferred. Touch not needed on this.
8. Light case - Need something ultra light that will keep all of this protected. Maybe design and print this one would be the best option.

Thursday, August 13, 2015

Keyloggers, password hash cracking, and more python fun

Worked through the keylogger over the past few days. Been having fun seeing what I can get it to pull. I want to see if I can pull location of mouse pointer too, that is next step.
Built a small python program that will crack password hashes, it is rather simple at the moment, but holds promise. I'll release source on these when they are working at least most of the way.

Python is a fun language and I use it for most simple things I do around my systems. Need to take a closer look at 3 as everything I do is in 2.7 still. I use python for organization and cleaning my HDDs. I am a habitual data hoarder. I have random text files of notes I wrote over 10 years ago... I think it's time to clean.
I use one script that looks at files last access date and generates a report for me. That way I can go look at them and see if I still want to keep them. I ignore system and program files. This is almost exclusively pointed at my data server. It also will read from a blacklist and will ignore files there (picture folders). I have it currently set at 6 months but probably should drop that down.

Tuesday, August 11, 2015

Kali 2.0 frustrations and successes

Well we all saw it happening, we watched it, we experienced it. The massive DDoS attack on the Kali Linux servers, along with the giant upgrade hug we all gave it. It was an eventful day. I saw people taking from 1 hr to 14 hours to download the 3.1 GB ISO. As of right now I have only been able to get the mini ISO to successfully install.
It is stalled out again. When I use the full ISO I get mount issues with using USB where it is looking for the the information under /cdrom instead of /media. Okay not a big deal
ln -s /media /cdrom
Oh wait it didn't like that either... Well I guess I could throw the ISO on there as well.
mount /media/kali2.iso /cdrom -o loop=/dev/loop1
waiting
waiting
waiting
well I guess that wont work in here... hmm
Back to the mini install. All of you are giving it the hug of death still 12 hours after release. I guess I can try a Debian mirror. Lets see if that works.
Decided on the usu.edu server.
That one failed, time to take a systematic approach... Or wait do I care to get this done today?
YES I DO!
Okay time to start at the top of the mirror list.
6 down so far all failing...
all seem to be failing at this point.
I'm going to crash I'll get it going tomorrow. We will see how servers are then.

I had a brain blast over the night. Seems that working tired caused me to slow down, after listening to my brain and sleeping I thought to just watch the mountings when it kept erroring out. It seems that it kept unmounting the /dev/sdb1 (flash drive) so every time it errored out I mounted it again. Did this 3 or 4 times throughout and it worked with out any other issues.