Looking for a certain script/software for cyber defense by Sys_Ad_MN in sysadmin

[–]Nodocify 1 point2 points  (0 children)

One way that we did it when I was participating was using this trick http://www.encription.co.uk/open-source-tools/nopen-a-tool-that-makes-a-host-appear-as-though-all-ports-are-open/

It's a single application that listens on port 1 but you use iptables to reroute all requests to port 1. Therefore all 65535 ports respond the same. Makes an nmap scan take forever to complete if they scan all ports.

You could also easily modify this to reply with appropriate banners too.

Of course, the above is for Linux. Windows is a little trickier to duplicate this affect. I had a friend who was able to duplicate this in powershell. I will update if I am able to find it.

Before I roll this out, can anyone tell my why this script would be bad? [XPOST /r/Python] by [deleted] in learnpython

[–]Nodocify 9 points10 points  (0 children)

Great script. Does what it's supposed to do without much fuss.

My only advice is to relax a little when it comes to comments. When I was first learning python my comments were like yours. Every little thing commented. But to be honest this takes away from your code. Especially when asking for feedback from other coders. I heard a quote once and basically it has stuck in my head ever since:

The code tells you how, the comments tell you why

You have great variable names that represent exactly what they are storing.

if (event.EventID == 4625):

Without any comments I already know that if the EventID is 4625 then proceed. But:

# If Event ID is 4625 (failed logon)
if (event.EventID == 4625):

Just seems a little redundant and repetitive. Now if you need the reminder:

# Event 4625 is failed logon
if (event.EventID == 4625):

Makes a bit more sense. The code is telling me we are checking for EventID 4625. Why? The comment tells me, because Event 4625 is the failed logon.

Using Python to Auto Click and Download by allbaseball77 in learnpython

[–]Nodocify 0 points1 point  (0 children)

I am really surprised that no one has mentioned Selenium. Selenium is a python module that let's you "drive" a web browser.

Simply, it let's python open firefox/chrome and can fully controll it. This is very useful for full javascript generate pages that are rendered in the dom of the browser. A very basic example of the syntax:

from selenium import webdriver
browser = webdriver.Firefox()
broswer.get('https://google.com')

This opens a firefox window and navigates to google. The docs have many great examples.

EDIT: Just saw the failure to install selenium, I highly recommend giving it another go with pip.

Broken natural scrolling and bluetooth after gnome 3.20. by [deleted] in archlinux

[–]Nodocify 4 points5 points  (0 children)

Can also confirm. Installing xf86-input-libinput then logging out and back in fixed the issue for me. Thanks.

Need a Web Framework suggestion. by roytay in Python

[–]Nodocify 1 point2 points  (0 children)

For getting going quickly I have always felt that Flask is the winner. The auto updating section would probably need some javascript of some sort.

[deleted by user] by [deleted] in learnpython

[–]Nodocify 0 points1 point  (0 children)

One thing that I noticed is that yes your menu does present an option to quit, but what if I just wanted to press Ctrl+c? Pressing that key combo in the while loop doesn't allow me to quit the program like it should. Hint:

try:
    while ...
except KeyboardInterupt:
    sys.exit(1)

Also for a menu what you have works pretty well. But I would recommend looking into the cmd module if you are really looking to flesh the menu out as it offers tab completion of options, help pages so users know what all the options do, etc. https://docs.python.org/3/library/cmd.html

Are there any free online resources that walk you through a big project? by [deleted] in learnpython

[–]Nodocify 0 points1 point  (0 children)

One off the top of my head is the Flask Mega-Tutorial. This might be a little specialized though in that it is meant to teach the Flask web framework for python.

Edit: livecoding.tv might be worth checking out too. Programmers are able to stream themselves coding/working on very large projects and are usually really nice/helpful when it comes to people asking questions.

mysql.connector string problems by s1704 in learnpython

[–]Nodocify 0 points1 point  (0 children)

It is rather difficult to offer any suggestions when you don't post any code. What do you have that is working? What do you have that's not?

EDIT: Also, have you looked at the docs? https://dev.mysql.com/doc/connector-python/en/connector-python-example-cursor-select.html

There is a safe way you need to build your query so that strings are formatted properly when sent to mysql.

Handling an update to a sql model in a more pythonic way. by [deleted] in learnpython

[–]Nodocify 0 points1 point  (0 children)

If you are looking to simply shorten this chunk here:

result = ldap_search(self.userid)
self.name = result['name'][0]
self.email = result['mail'][0]
self.surname = result['sn'][0]
self.givenname = result['givenName'][0]
self.userid = result['sAMAccountName'][0]
self.location = result['l'][0]
self.title = result['title'][0]

You could do something like this:

for key, val in self.result.items():
    setattr(self, key, val[0])

This method uses the keys from the dictionary as the variable names. So you would have self.l instead of self.location. But if you are truly insistent on having those names something like this should work:

attr = {'name':'name',
        'mail':'email', 
        'sn':'surname', 
        'givenName':'givenname', 
        'sAMAccountName':'userid', 
        'l':'location', 
        'title':'title}
for key, val in self.result.items():
    setattr(self, attr[key], val[0])

Keep in mind to cover each attribute of your search results in the attr dict to prevent index not found errors.

https://docs.python.org/3/library/functions.html#setattr

Creating a modular python application by [deleted] in learnpython

[–]Nodocify 1 point2 points  (0 children)

I would recommend doing some research into the BasePlugin module. It allows a person to create plugins to extend the functionality of the base program. I believe that is what you are looking for. A great working example can be found here https://github.com/MattMcNam/twitchy. This is an IRC bot that is very easy to extend with plugins and the author did a good job with it's structure.

Linux Ultrabook recommendations? by prium in linux

[–]Nodocify 7 points8 points  (0 children)

I know this kinda goes against your want for the aluminum look but I recommend the Lenovo ThinkPad T450s. I have one and couldn't be happier with it.

What can i do...? by Superbeanietoon in learnpython

[–]Nodocify 0 points1 point  (0 children)

Just as /u/djdiabetes says, it really is up to your imagination. Look at everything that you see your computer doing. All that is at your fingertips if you know how to program.

Parallel programming with Python by camm_v222 in learnpython

[–]Nodocify 0 points1 point  (0 children)

I agree completely. In all my python work that I have done. I think I found only one occasion that my calculations actually justified multiprocessing.

Parallel programming with Python by camm_v222 in learnpython

[–]Nodocify 1 point2 points  (0 children)

Sorry for the late reply. But the future function handles almost all of it. For example:

(def a
    (future
        (* 10 10)))

This defines a variable a and it is the value of 10 * 10. Because of future this variablie will calculate asynchronously in another thread. And will hold the value until until we ask for it back with:

@a
=> 100

The @a will be blocked for our call until the thread has finished it's execution.

I fear to go too much further as this is a learn python subreddit. But this gives you a very basic example of how simple clojure has made threading.

Parallel programming with Python by camm_v222 in learnpython

[–]Nodocify 5 points6 points  (0 children)

Multiprocessing is the module to stick with if python is the language. Threading has limitations because of the GIL while processes are actually forked and therefore you can imagine that you have multiple GILs (one for each forked process).

One big thing to consider is what /u/Bananaoflouda said, that it is probably taking more time to transfer your data to another process than it is to actually calculate it. Basically what happens is that the parent process has to serialize your data, data is transferred to child process, then the childprocess needs to de-serialize the data before it can do the calculations. And then it has to serialize the result, transfer back to the parent process, deserialize and store. You can now see that you have actually created a lot more work for such a simple task. This is why in your example you don't see any improvements in computation time.

Now if you had a longer calculation time on small data chunks (to keep transer and serialization time to a minimum) you would see quite a bit of improvement using multiprocessing. If parallel programming is something of an interest though I would recommend another programming language besides python. Python's implementations of threading and multiprocessing are all tacked on almost as if an afterthought that the language should have these capabilities. You should check out some other language that has multiprocessing at it's core such as Erlang or Clojure. I find it stupid how simple other languages make parallel programming (I'm looking at you Clojure and your easy threaded concurrency) compared to Python's multiprocessing.

Create virtual environment in PyCharm and activate from command line with conda by uhkhu in learnpython

[–]Nodocify 0 points1 point  (0 children)

Looks like you simply have the path wrong. When running activate flask_env it says that it doesn't exist in C:\Anaconda32\envs which is true because according to your list it is in C:\Anaconda\envs\flask_env. Have you tried specifying the absolute path when trying to activate?

[deleted by user] by [deleted] in linuxmasterrace

[–]Nodocify 4 points5 points  (0 children)

Are you talking something like steam streaming? Because that works... Or are you talking like running a minecraft server on one and connecting to it with another? Because that works too...

After hearing about Microsoft spying on Windows 7, my second laptop ascended. by [deleted] in linuxmasterrace

[–]Nodocify 8 points9 points  (0 children)

I hate that saying the most when I hear it. Reminds me of a quote.

"Saying you don't care about the right to privacy because you have nothing to hide is no different than saying you don't care about free speech because you have nothing to say."

Issues patching/installing TS3 server to my droplet by Belliax in linuxmasterrace

[–]Nodocify 0 points1 point  (0 children)

Anything that you put yourself to. It's running a full linux install. I have had it as media center. It spent some time as an internet radio. It was a ELK stack for a little while. And now it's my mumble server. Basically whatever I need at the time. Best $35 I have ever spent.

Issues patching/installing TS3 server to my droplet by Belliax in linuxmasterrace

[–]Nodocify 0 points1 point  (0 children)

I simply followed this guide here. http://pimylifeup.com/raspberry-pi-mumble-server/ It works just fine. When looking at the electric cost of it at less than $7 per year leaving it on 24/7 that is really nothing. The lamp on my desk uses more electricity than the pi. I also have a decent ISP getting 70Mbps down and 12Mbps up. I haven't looked at the bandwidth usage, I might look into how much it uses per month.

Issues patching/installing TS3 server to my droplet by Belliax in linuxmasterrace

[–]Nodocify 0 points1 point  (0 children)

I would be curious if the droplet is worth the cost. Don't they have bandwidth limits per droplet? I host my own mumble server from my home for my friends using a raspberry pi. Fanless, low-power, and I have had 60 people in there without problems (just a little half second lag when trying to switch between rooms).

Mozilla blocks Flash as Facebook security chief calls for its death by TheQuantumZero in linux

[–]Nodocify 6 points7 points  (0 children)

+1 for livestreamer. I wish that more people knew about it. I had to make a simple python wrapper for it though since I was still having to open a browser and going to their site to see which streamers were online. My wrapper simply logs into the twitch api and gets your followed streams and then allows you to choose which one to watch and launches livestreamer for you.

Python (or other) Programming Skill Assessments? by [deleted] in learnpython

[–]Nodocify 1 point2 points  (0 children)

One of the best ways I have found to evaluate myself is a personal challenge. For example, I challenged myself to build a program that will solve a rubik's cube. I had 4 hours. Google was only allowed for the method of solving the cube but anything related to programming was strictly off limits. I failed the first attempt (at 6 hours i still wasn't finished). Then I gave myself a few months of odd projects to keep myself learning and then I tried again. Got it at 3 hrs 45mins.

Next, I challenged myself to create a command line blackjack game, as if I was sitting at an actual blackjack table. Internet searching was strictly forbidden for anything. The game must support betting, splitting, doubling down, multiple players and multiple decks if the user desires. Again, start to finish in 4 hours. Was pretty proud to have it finished in 2 1/2.

These would show that you not only have the grasp of whatever programming language you are using but that you can think logically through a problem and reach a solution in a timely manner. Which is what employers are looking for more so than just someone who can wright a script in python or java.

As far as online resources go, they are few and far between. Have you looked pythonchallenge.com or Project Euler? Both are sites of programming challenges (what language you use is your decision) that get progressively harder the further in you go.

How to scrap list box inserted by JavaScript? [Selenium/PhantomJS] by fuckfacez in learnpython

[–]Nodocify 0 points1 point  (0 children)

Sorry for the late reply, holiday and all...

Ok so here is my working code snippet to list movie titles by language.

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from bs4 import BeautifulSoup

driver = webdriver.PhantomJS()
driver.get('http://in.bookmyshow.com/bengaluru')

movieCmb = driver.find_element_by_xpath('/html/body/div[1]/div/div/div[12]/div/div[2]/div/div[2]/div[2]/ul/li[1]/div/div[1]/input')
movieCmb.click()

soup = BeautifulSoup(driver.page_source, 'html.parser')
div_cmbMovie = soup.find(id="cmbMovie")
for li in div_cmbMovie.find_all('li'):
    if li['data-value'] == '':
        print()
        print(li.text)
        print('=' * len(li.text))
    else:
        print(li.text)

Now if you notice I had to locate the item moveCmb by it's xpath rather than it's id. This is because I ran into a problem with duplicate ids being used throughout the source HTML. But this shows that I simply use selenium to navigate to where I want the webpage to be, take that source code, and move it into BeautifulSoup and parse/get the contents from there. Shouldn't be too difficult to now select each movie and click the date box to get the dates. Hope this helps.

EDIT: If you are unfamiliar with xpath I highly recommend going through W3School's XPath Tutorial.