-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsource.py
More file actions
54 lines (40 loc) · 1.6 KB
/
source.py
File metadata and controls
54 lines (40 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# source file that will be obfuscated
import os
def get_linux_release_info():
"""Get Linux release info from /etc/os-release."""
# Check if the file exists
release_file = "/etc/os-release"
if not os.path.exists(release_file):
print("OS release file not found. This might not be a Linux system.")
return None
# Dictionary to store release information
release_info = {}
try:
# Read and parse the file
with open(release_file, "r") as f:
for line in f:
if not line or "=" not in line:
continue
# Split key and value
key, value = line.strip().split("=", 1)
# Remove quotes from value
value = value.strip("\"'\n")
# Store in dictionary
release_info[key] = value
# Print key release information
print("\nLinux Release Information:")
print(f"Distribution: {release_info.get('NAME', 'Unknown')}")
print(f"Version: {release_info.get('VERSION', 'Unknown')}")
print(f"Version ID: {release_info.get('VERSION_ID', 'Unknown')}")
print(f"Pretty Name: {release_info.get('PRETTY_NAME', 'Unknown')}")
return release_info
except Exception as e:
print(f"Error reading release file: {e}")
return None
# Main execution
if __name__ == "__main__":
# Check if running on Linux
if os.name == "posix" and os.path.exists("/etc/os-release"):
release_details = get_linux_release_info()
else:
print("This script is designed for Linux systems.")