Skip to main content

Posts

Showing posts with the label Python tutorial

Control your PC from Python Code

Hey guys, One of the easiest programming languages in the World is our Python. Here this post is intended for those who want to learn the hacking techniques! Here I would like to share simple 4lines of Python hack tricks that make shutdown or restart your PC. The logic here is that have the function contains the CMD Command line 'shutdown' with forceful(/s) timeout as 1 minute. Shutdown logic is here... import os def shutdown(): os.system("shutdown /s /t 1") shutdown() Restart logic is here import os def restart(): os.system("shutdown /r /t 1") restart() Jump to Linux VM and same thought to execute the same script then it failed! "Must be root." The solution there you need to be superuser to shutdown your Linux machine. To have better understand about the shutdown command in Linux operating system, used the --help option. [vagrant@mydev ~]$ sudo shutdown --help shutdown [OPTIONS...] [TIME] [WALL...] Shut down the system. ...

Python Sequence Data Types: List, tuple

Python Datatypes by SujithKumar from Sujith Kumar In this I would like to discuss about Python data types. Usually Python don't required any variable declarations with datatype but we should aware when we are dealing with the variable values and how it stores what type of data. Let's jump into our exploration on Python data types. Python Mutable vs Immutable datatypes In simple way to understand this using id() function that returns address of the variables. Mutable data type means the variable stores the data at one address even different operations (+,-,/,*,%) on the variable. The content of objects of immutable types cannot be changed after they are created. Mutable objects bytearray list set dict Immutable objects int float long complex str tuple frozen set Lets test a int data type and a list data type to evaluate the immutable values with int data type while doing arthematic operation on it. Similarly list example shows how mutable t...