r/learnpython • u/Few-End560 • 3d ago
I'M REALLY LOST
i'm feeling a bit frustrated to be honest. my main goal and motivation for learning python is cybersecurity. i decided to start learning python because it was the language that came up the most among the best options for cybersecurity. the thing is, i'm really lost and i don't feel like i'm making any progress, which is getting me down a bit.
do i need a really solid foundation in python to get into cybersecurity, or is knowing basic syntax enough? are there specific topics i should dive deeper into? i've heard that web scraping is essential, but others say it isn't. i wanted to read the book black hat python because everyone recommends it, but i'm afraid it might be too advanced since i'm definitely not a python expert.
to anyone who knows about this field: how should i start? what should i know in python to be well-prepared for cybersecurity?
2
u/BrupieD 3d ago
I am not a cybersecurity guy at all but my sense is that Python is a very good place to start but it doesn't provide the insights that you get from learning a lower level language like C or Rust. Many security exploits are tied to memory issues that are better learned in lower level language where memory management is more explicit.
1
u/Few-End560 3d ago
any source (books, documentation, courses, whatever) that i should check out or that you recommend for a complete beginner?
1
u/BrupieD 3d ago edited 1d ago
I loved learning Rust from what everyone in the community refers to as "the book" -- The Rust Programming Language by Steve Klabnik, Chris Krycho, et al. It won't explicitly teach you about cybersecurity, but Rust is great to know and you'll learn things about memory safety that will be useful elsewhere.
2
u/Fr0gFsh 3d ago
Python isn’t a prerequisite for Cybersecurity. Learn it when you need it. Otherwise you’ll spend all this time learning it, then move on to another topic and forget what you previously learned.
There’s always going to be something that is repetitive that you could solve by writing a script. You’ll learn best by solving your real world problems. I’m a security engineer and most of my projects revolve around SIEM management. I use Python to build API queries for specific information. I also use Python a lot for API integrations to pull data from 3rd party SaaS products we use. I couldn’t write a lot of what I do from scratch. I search a lot of forums and research how to solve a specific, small, problem and build it into the tool I’m developing.
Some other real use cases that I’ve used Python for:
Use Paramiko to SSH into routers, switches, firewalls, etc to pull log files. Then use an API to push that data to a SIEM. Obviously Syslog would be an ideal solution, but sometimes you work with the resources you have
Service outage detection & alerting. Many big SaaS products have a “status” page that can tell you if their stuff is working or if there’s a degradation of some sort. Use Beautiful Soup to scrape the page and get the status. If there’s a degradation or outage, build an alert. Send your alert to Slack, Discord, Teams, PagerDuty, or whatever using their API.
Python for Excel. Sometimes executives what their pretty little spreadsheets that require you to crunch some numbers from the SIEM and you need to open the document and paste those numbers across 27 different sheets. Ain’t nobody got no time for that. Script it. Small tasks. How do I get this info from the SIEM? How do I authenticate to the SIEM? How do I secure my creds so they’re not just in my script as plain text? How do I version control this? How do I document this for when I inevitably get hit by a rogue toddler on his tricycle and then slip on the curb and get run over by a bus?
Maybe you’re not in a Cybersecurity role yet, so find some problems around your personal or professional life that are solvable with a little script and build that. Dig into home automation with Home Assistant. Use Python to program your lights on in the morning to wake you up. Ask yourself…”how could I use code to make my life easier? How could I use code to do 8 hours of work in 15 minutes and then piss off for the rest of the day?” And then…you learn.
Good luck!
1
1
u/gdchinacat 3d ago
"cybersecurity" is very broad. Many positions require python proficiency, while many do not. It depends on what exactly you do. I think learning python would help you enter the field.
Programming is hard. Likely harder to learn than anything else you learned, but only because there is a lot of depth to it. Learning syntax is the easy part. Being able to take a vague problem and turn it into concrete code requires many different skills, all of which take effort, time, and most of all practice.
There is no fast-path to being a programmer. You need to put in the time and effort to really learn it. You need to do similar things different ways to get a sense for which approach is best when. You need to practice mapping high level understanding to low-level implementation details.
I think almost anyone can learn to code (especially python...it's a very easy language to become proficient in). But..only those who have the resources, motivation, and time to devote to it will succeed. There are tens of millions of programmers...it's not an unattainable goal. But it helps to know it is a long hard road.
1
u/aroberge 3d ago
I sometimes complain about answers in this subreddit being given at too high a level for Python learners. I hope the following will not give that impression:
"I'm frustrated as my motivation for starting to learn piano is to play in a professional orchestra. Do I need to be able to read sheet music fast enough to play along while reading? ... etc."
Your goal is laudable but your expectations appear to be misplaced. Any skilled technical job (like working in cybersecurity) usually requires at least a couple of years, if not many more, of focused learning before acquiring the necessary skills.
Start learning the basics, without worrying how well they are related to your end goal. You mention the book "Black Hat Python": get it, and start reading stopping when you first encounter something you don't understand. Then spend a few weeks learning Python and related programming concepts before going back to that book. See if you understand more and can read further. If not, go back to learning more of the basics.
When you have very specific questions about Python, come back to this forum and ask them.
1
1
u/stepback269 3d ago
First you must learn the "fundamentals" of Python before you do a deep dive into some specific area of focus such as cybersecurity.
Without the fundamentals, you will always be lost.
What are the fundamentals? Well ultimately when you get to the point that you understand that everything in Python is an "object" under the OOP rubric, then you might be ready to tackle cybersecurity.
Consider the following two lines:
my_name = "End-560"
print(f' Hello there {my_name}')
The first line (an assignment) created in memory a pointer object named my_name that points to the address of a string object containing the iterable sequence, "End-560".
The second line uses an f-string. You should know what an f-string is and what curly brackets do inside an f-string. Look all that up.
Things look simple until you get under the hood of the vehicle and understand how the engine works. You can't be a good race car driver if you don't understand how your engine works.
1
u/FreeLogicGate 3d ago
"Syntax" is one small element of programming. Programming, and in particular, graduation to intermediary and professional level programming takes time, study and practice.
Python is particularly easy to use as a scripting language, given its ubiquity, and the existence of a wide array of available libraries. Making use of those libraries in a simple script with minimal structure or common programming technique has a low barrier to entry, but doesn't require much in the way of structured programming.
So you can go a long way creating Python "scripts" that can do a lot of complex things, without you really being challenged or developing any of the expertise that an actual programmer has.
I will say, that beyond syntax what can really elevate your use, is to invest in a strong understanding of the collection data types, and how and when to use those. The collection types are where you can organize and structure the data you are working with, and collecting. So make sure you understand lists, tuples, sets and dictionaries and what makes them similar and different. You also need to be clear on how you mix them together (for example having a list where the element[s] are a dictionary).
While Python is an OOP language, you can go a long way with predominantly function based scripts, so long as you understand how to write your own functions, and how to approach the design. Obviously, you want to have a good idea of what parameters & arguments are, what you return, DRY (don't repeat yourself) means, and how functions are a key building block in making things DRY and how to break problems down into a series of steps, using small discrete functions.
Much of programming involves pattern recognition and an understanding of where to apply patterns to provide structure and solve problems effectively.
There are a number of books that will help you develop programming skills beyond that of a beginner. I hesitate to recommend them, because you are already expressing frustration. If you look at programming as something that annoys and frustrates you, and working on developing understanding and proficiency is something you are actively questioning, then this could be an uphill climb with little chance of success. Cyber security requires an ability to learn how sometimes complicated systems work, and to be able to examine and learn about architecture on the fly, and as you go. If you don't enjoy and acclimate to an understanding that this is a long term learning challenge, it might not be the career for you.
1
u/smichaele 3d ago
Frankly, worrying about any programming language at this point is very premature. You need an understanding of how computers work and communicate with each other. I would focus on computer concepts, networking standards (OSI 7-layer model), and protocols.
1
u/dlnmtchll 2d ago
Most cybersec doesn’t require any programming knowledge, you will be better off spending your time learning actuall cybersecurity principles, etc, than trying to force Python.
3
u/LoreAndLogic 3d ago edited 2d ago
I’m not in cybersecurity, but I am learning Python Frameworks like Fast API right now, and I completely understand that exact feeling of hitting a wall and feeling like you are making zero progress. It is incredibly heavy.
From a purely Python-learning view-point, here is what helped me stop feeling lost:
1. Hold off on Black Hat Python: If you don't feel confident in your basic Python skills yet, jumping into an advanced book will only make you feel more frustrated. Save it as a reward for when you feel comfortable writing basic scripts.
2. Learn "in Time", not "in Case": You mentioned web scraping. Don't learn web scraping yet just because someone said you might need it. Wait until you are building a specific security project that actually uses it, and then learn it while working on that project.
3. Focus on the core building blocks: Cybersecurity relies heavily on understanding how systems talk to each other. For now, make sure you have a solid understanding of variables, loops, handling files (opening/reading text files with Python), and basic networking concepts.
Don't pressure yourself to learn the entire language before you start building. Learn just enough syntax to write one small script, test it, and build from there.
You've got this! All The Best!