惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

Black Hills Information Security, Inc.

Same Problem, Different Angles: When Red Team and Blue Team Actually Talk to Each Other How to Identify and Exploit New Vulnerabilities Swapper – A Pure Regex Match/Replace Burp Extension A Practical Guide to BloodHound Data Collection Network Engineering Basics Signed, Trusted, and Abused: Proxy Execution via WebView2 Getting Started In Pentesting – Advice From The BHIS Pentest Lead Cloud Security: Tips and Resources for Securing the Cloud Lessons From A Chatbot Incident How to Lead Effective Tabletops Understanding GRC: How to Navigate Risks and Compliance Standards The “P” in PAM is for Persistence: Linux Persistence Technique Malware Analysis: How to Analyze and Understand Malware OSINT: How to Find, Use, and Control Open-Source Intelligence What to Do with Your First Home Lab When the SOC Goes to Deadwood: A Night to Remember Social Engineering and Microsoft SSPR: The Road to Pwnage is Paved with Good Intentions Common Cyber Threats Finding the Right Penetration Testing Company Deceptive-Auditing: An Active Directory Honeypots Tool The Curious Case of the Comburglar How to Set Smart Goals (That Actually Work For You) Inside the BHIS SOC: A Conversation with Hayden Covington Abusing Delegation with Impacket (Part 3): Resource-Based Constrained Delegation Why You Got Hacked – 2025 Super Edition Abusing Delegation with Impacket (Part 2): Constrained Delegation Abusing Delegation with Impacket (Part 1): Unconstrained Delegation GoSpoof – Turning Attacks into Intel Model Context Protocol (MCP) Bypassing WAFs Using Oversized Requests Getting Started with AI Hacking Part 2: Prompt Injection Wrangling Windows Event Logs with Hayabusa & SOF-ELK (Part 2) DomCat: A Domain Categorization Tool Wrangling Windows Event Logs with Hayabusa & SOF-ELK (Part 1) Microsoft Store and WinGet: Security Risks for Corporate Environments Default Web Content MailFail Commonly Abused Administrative Utilities: A Hidden Risk to Enterprise Security Stop Spoofing Yourself! Disabling M365 Direct Send Bypassing CSP with JSONP: Introducing JSONPeek and CSP B Gone Offensive Tooling Cheatsheets: An Infosec Survival Guide Resource DNS Triage Cheatsheet GraphRunner Cheatsheet Burp Suite Cheatsheet Impacket Cheatsheet Wireshark Cheatsheet Hashcat Cheatsheet EyeWitness Cheatsheet Nmap Cheatsheet Netcat (nc) Cheatsheet Hunt for Weak Spots in Your Wireless Network with Airodump-ng from the Aircrack-ng Suite Detecting ADCS Privilege Escalation Vulnerability Scanning with Nmap Getting Started with NetExec: Streamlining Network Discovery and Access How to Use Dirsearch Augmenting Penetration Testing Methodology with Artificial Intelligence – Part 3: Arcanum Cyber Security Bot How to Design and Execute Effective Social Engineering Attacks by Phone Abusing S4U2Self for Active Directory Pivoting Why Use a Macro Pad? Espanso: Text Replacement, the Easy Way Caging Copilot: Lessons Learned in LLM Security Augmenting Penetration Testing Methodology with Artificial Intelligence – Part 2: Copilot Augmenting Penetration Testing Methodology with Artificial Intelligence – Part 1: Burpference Intercepting Traffic for Mobile Applications that Bypass the System Proxy How to Root Android Phones Communicating Security to the C-Suite: A Strategic Approach Offline Memory Forensics With Volatility Getting Started with AI Hacking: Part 1 Go-Spoof: A Tool for Cyber Deception How to Test Adversary-in-the-Middle Without Hacking Tools Canary in the Code: Alert()-ing on XSS Exploits How to Hack Wi-Fi with No Wi-Fi Why Your Org Needs a Penetration Test Program Burp Suite Extension: Copy For Light at the End of the Dark Web Wi-Fi Forge: Practice Wi-Fi Security Without Hardware Avoiding Dirty RAGs: Retrieval-Augmented Generation with Ollama and LangChain Gone Phishing: Installing GoPhish and Creating a Campaign 5 Things We Are Going to Continue to Ignore in 2025 John Strand’s 5 Phase Plan For Starting in Computer Security Questions From a Beginner Threat Hunter GRC for Security Managers: From Checklists to Influence AI Large Language Models and Supervised Fine Tuning Attack Tactics 9: Shadow Creds for PrivEsc w/ Kent & Jordan One Active Directory Account Can Be Your Best Early Warning Introduction to Zeek Log Analysis Indecent Exposure: Your Secrets are Showing Creating Burp Extensions: A Beginner’s Guide Pitting AI Against AI: Using PyRIT to Assess Large Language Models (LLMs) The Top Ten List of Why You Got Hacked This Year (2023/2024) ICS Hard Knocks: Mitigations to Scenarios Found in ICS/OT Backdoors & Breaches Intro to Data Analytics Using SQL Finding Access Control Vulnerabilities with Autorize The Detection Engineering Process Cyber Risk Lessons We Can Learn From Hurricane Preparedness Intro to Desktop Application Testing Methodology What Is Penetration Testing? Adversary in the Middle (AitM): Post-Exploitation Pentesting, Threat Hunting, and SOC: An Overview QEMU, MSYS2, and Emacs: Open-Source Solutions to Run Virtual Machines on Windows
It’s Always Nice to Have Cron-ies!
2016-08-16 · via Black Hills Information Security, Inc.

I have been asked by some friends, (not very Linux proficient friends) to share this. I thought I would create a blog post and share with all. We all had to start somewhere and sometimes we forget that not everyone is an avid Linux user. Just like I’m not an avid beer maker….. (yet!)

I was hanging out with a couple of my old Admin friends about a month ago and the question of VPN’s came up. Everyone commented on what VPN they use at work and at home. OpenVPN was mentioned as it is a great software solution and found to be rather easy to implement. One of them mentioned that they wish they would implement a scheduling solution so that they could limit access during updates and also have the flexibility to allow interns only access during certain hours. We all got a good laugh out of that but then realized he was serious. This lead to a deep discussion about the companies that everyone works or had worked for and the red tape that seems to run along with them. Did I mention that I love BHIS! I think that if there was red tape it got handed out at a conference somewhere with one of our awesome T-shirts.

Keep fighting my friends, keep fighting!

After I got home I thought about the comment of limiting access and the ability to have a schedule in place for the OpenVPN solution. For some reason I have this curse which causes my mind to run crazy with small trivial things that I somehow twist into a challenge. I believe that my friends do this to me on purpose sometimes because they are just evil like that. I have to admit that a lot of the stuff that they come up with is really trivial but sometimes it poses as a challenge far more than just solving a solution, in which it could include solutions for other problems.

Don’t ask!

The next day I decided to look further into the scheduling solution since I have an OpenVPN server installed in my lab at home. With a little research on the OpenVPN website I found command line syntax to disable user access as well as suspend their account. The following commands were found on the OpenVPN website https://docs.openvpn.net/docs/access-server/openvpn-access-server-command-line-tools.html#session-management

Ban a User Command Line Syntax for OpenVPN Server

Disconnect a User Command Line Syntax for OpenVPN Server

Now that I know the command line syntax it was time to create a bash script so that it could be called later to disconnect and ban a user. Notice there is a nice addition to the disconnect user command which lets you give them a reason for the disconnect.

In my past life I used to work for a contract manufacture of printed circuit boards which consisted of computer motherboards, telephone equipment, SCSI controllers, medical devices and so on. Most of the functional bench testing was done with cron jobs because almost always the first part of the test was to set the time to the default (again with a script) so that times it took to test could be caught and utilized to determine if there were propagation delay issues, especially in CPU and Ram timing. Therefore, we would run bash scripts to launch various tests at specific points in time. This was very affective in finding timing issues with the bus speeds of the devices and seemed to be the easiest way to implement them at that time. Now I am sure there are far better ways to do this.

Creating a bash script is really easy. Login via SSH, escalate to root (sudo su), then create a directory to hold your bash scripts. Then cd into that directory. Root access is needed since it is required to run the OpenVPN scripts.

medic@openvpnas:~# mkdir ~/scripts

medic@openvpnas:~# cd scripts

medic@openvpnas:~/scripts#

Then use VI or Nano to create the name of the bash script (e.g. vi discbanuser.sh or nano discbanuser.sh). This will open a blank file called discbanuser.sh in the current directory.

medic@openvpnas:~/scripts# nano discbanuser.sh

 Then input the information below in order to run the commands you have to be in the scripts directory below. This is a different directory than the directory you just created.

Batch Script to Disconnect and Ban the User

Now we have our batch script for disconnecting and banning a user from our OpenVPN lets create another Bash Script to unban or allow them to connect again to the VPN Server. This will be created in the same ~/scripts directory as the discbanuser.sh and we will call it unbanuser.sh.

Bash Script to Allow User to Connect to VPN

We now have our bash scripts created therefore it is time to make sure the permissions are correct for these files to be executed. Not that it is:  ls –(lowercase L).

medic@openvpnas:~/scripts# ls –l

Total 8

-rw-r--r-- 1 root root 1010 Aug  8 15:30 discbanuser.sh

-rw-r--r-- 1 root root  428 Aug  8 15:33 unbanuser.sh

medic@openvpnas:~/scripts#

Note that the files are not allowed to be executed so we need to change that.

medic@openvpnas:~/scripts# chmod 755 discbanuser.sh

medic@openvpnas:~/scripts# chmod 755 unbanuser.sh

medic@openvpnas:~/scripts# ls –l

Total 8

-rwxr-xr-x 1 root root 1010 Aug  8 15:30 discbanuser.sh

-rwxr-xr-x 1 root root  428 Aug  8 15:33 unbanuser.sh

medic@openvpnas:~/scripts#

Now the bash scripts are executable we can work to schedule them with crontab.

Crontab or you may have heard of them as Cron Job or Cron. Is a scheduler for Linux. All Linux users have used them for one task or another as it may be used for scheduling reboots, updating and various other tasks. There is a short funny read about an individual who created different scripts to automate his most mundane tasks which can be found here: https://what.thedailywtf.com/topic/17997/now-that-s-what-i-call-hacker In fact I am still waiting for BHIS to get us a coffee maker that hooks up to the network…….

Moving on…

I have an OpenVPN virtual machine running so to schedule a task just type following command:

medic@openvpnas:~/scripts# crontab -e

This will open up crontab file for the current user which is what the –e means.

The crontab file it gives you information about what syntax to utilize as you can see below:

Crontab File with Calls to Bash Scripts

As you can see by the file I have already placed calls to my discbanuser.sh and unbanuser.sh scripts. These tasks will run at 10:00pm and 10:30pm respectively on the first day of the week. Now we can save the file and then check to see if it works.

I logged into the VPN as ricktest, a user I created earlier. I waited for the message to arrive that I had been disconnected from the server.

I got the message that I was disconnected as well as the message that I included in the command within the bash script. That worked well.

Now to try and connect to the VPN Server again:

Just what was expected!

I then tested again after the script had unbanned the account and I was again able to login.

Even though this is simple example, hopefully it will give those newbies to Linux and my friends a foothold into the world of crontab. As you can see the sky is the limit as what scheduled tasks and bash scripting can be used for.

Make sure you check out the link mentioned previously in this blog for some more fun and advanced examples.