Skip to main content

Posts

Linux: How To Identify a Zombie/Defunct Process and Clean It

Every process has a parent process and the parent processes are responsible for creating ( forking ) child processes and cleaning them from the process table after they finished their execution. When a process finishes its execution it leaves an exit status to be sent to the parent process, then it becomes a zombie.
Recent posts

Renewing Expired Samba DC Certificate

When It's first installed, Samba4 autogenerates self-signed certificate files(ca.pem, cert.pem, and key.pem). These files will be expired 700 days after creation. With the following procedure, the certificate can be renewed.

Audit and Send User commands to Syslog in Linux

It is important to monitor every command a system admin or operator executed on the servers. Additionally logging the changes made to systems are required to comply with information security legislation like ISO 27001. In Linux, it can be possible using a simple function. Once you have a remote Rsyslog Server configured, append the following function and trap to /etc/profile file. /etc/profile file is sourced when a shell login occurs. So every time a command is executed, trap named trap_ cmd_to_syslog calls the send_cmd_to_syslog function. ${remote_host} is extracted from the $(who am i)  command. $BASH_COMMAND is the command currently being executed or about to be executed.

How to pass through CSRF protection for Python-Django application using Curl

Django's CSRF Middleware is used to protect users from cross site request forgeries. When making an http request it must contain X-CSRF-Token header provided by Django web framework. Web browsers do this automatically by making a custom request firstly and get the token. Then use this token to pass CSRF protection. I just want to show how to simulate the same behavior by using curl command. Note that the http://<your-domain>/<your-url-path> is not a LoginRequired url. When the first curl command run, the response is saved into /tmp/cookie.txt and the contents look like: # Netscape HTTP Cookie File # http://curl.haxx.se/docs/http-cookies.html # This file was generated by libcurl! Edit at your own risk. #HttpOnly_ www.yourdomain.com FALSE / TRUE 1642434093 csrftoken A123b2O9LPLFcGe7zODhTNpEKKYKYp987B7u3E0t1FDDDWTGYbXHu83dEek6P3cN X-CSRF-Token can be extracted from this file, then we run the second curl command for the actual request.