Privilege Escalation: How to build RPM payloads in Kali Linux

From time to time, you may come across a system that enables you to run yum or dnf as an elevated user. This scenario is quite enticing for penetration testers because it is a potential privilege escalation vector. But, what happens if we don’t have permissions to create RPM packages on the victim machine and we don’t have a CentOS or RedHat system easily available to us? The solution to this problem is to create an RPM package on our Kali Linux attacking machine and move it over to the victim machine.