Hacker Scripts..Based on a true story

An worker who had left the company had some scripts to automate his life..his coworker has posted this gem to a russian bash.org.

Based on a true story:

xxx: OK, so, our build engineer has left for another company. The dude was literally living inside the terminal. You know, that type of a guy who loves Vim, creates diagrams in Dot and writes wiki-posts in Markdown… If something – anything – requires more than 90 seconds of his time, he writes a script to automate that.

xxx: So we’re sitting here, looking through his, uhm, “legacy”

xxx: You’re gonna love this

xxx: smack-my-bitch-up.sh – sends a text message “late at work” to his wife (apparently). Automatically picks reasons from an array of strings, randomly. Runs inside a cron-job. The job fires if there are active SSH-sessions on the server after 9pm with his login.

xxx: kumar-asshole.sh – scans the inbox for emails from “Kumar” (a DBA at our clients). Looks for keywords like “help”, “trouble”, “sorry” etc. If keywords are found – the script SSHes into the clients server and rolls back the staging database to the latest backup. Then sends a reply “no worries mate, be careful next time”.

xxx: hangover.sh – another cron-job that is set to specific dates. Sends automated emails like “not feeling well/gonna work from home” etc. Adds a random “reason” from another predefined array of strings. Fires if there are no interactive sessions on the server at 8:45am.

xxx: (and the oscar goes to) fucking-coffee.sh – this one waits exactly 17 seconds (!), then opens an SSH session to our coffee-machine (we had no frikin idea the coffee machine is on the network, runs linux and has SSHD up and running) and sends some weird gibberish to it. Looks binary. Turns out this thing starts brewing a mid-sized half-caf latte and waits another 24 (!) seconds before pouring it into a cup. The timing is exactly how long it takes to walk to the machine from the dudes desk.

xxx: holy sh*t I’m keeping those

Source

Github scripts

Enable/Disable Proxy Service in OSB via ANT+Python

Below is the configurable code for developers to maintain an ant script to be able to control(Enable/Disable) Proxy Services via Ant Script.

Files:


WLSTbuild.properties

weblogic.home.dir=<OSB Home>/wlserver_10.3
weblogic.lib.dir=${weblogic.home.dir}/server/lib


build.properties

fmw.home=<OSB Middleware Home>
wls.username =<Weblogic User Id>
wls.password =<Weblogic Password>
wls.server = t3://:<Weblogic Host>:<Weblogic Port>
service.script=osb_enable_service.py
service.project="<Project Name>/<Sub Project Name or 'ProxyServices' >"
service.name =<Proxy Name>
service.action = <disable/enable>


build.xml

<?xml version="1.0" encoding="windows-1252" ?>
<project name="ServiceControl" default="ServiceControl">
   <property file="./build.properties"/>
   <property file="./wlstbuild.properties"/>
   <taskdef classname="weblogic.ant.taskdefs.management.WLSTTask" name="wlst">
      <classpath>
         <pathelement location="${weblogic.lib.dir}/weblogic.jar"></pathelement>
      </classpath>
   </taskdef>
   <target name="ServiceControl">
      <echo>${weblogic.lib.dir}</echo>
      <wlst filename="${service.script}" debug="true" failonerror="false"
            arguments="${wls.username} ${wls.password} ${wls.server} ${service.project} ${service.name} ${service.action}">
         <classpath>
            <pathelement location="${weblogic.lib.dir}/weblogic.jar"></pathelement>
            <pathelement location="${fmw.home}/<OSB Installation Folder>/lib/sb-kernel-api.jar"></pathelement>
            <pathelement location="${fmw.home}/<OSB Installation Folder>/lib/sb-kernel-impl.jar"></pathelement>
            <pathelement location="${fmw.home}/<OSB Installation Folder>/lib/osb-coherence-client.jar"></pathelement>
         </classpath>
      </wlst>
   </target>
</project>

osb_enable_service.py

from com.bea.wli.sb.management.configuration import SessionManagementMBean
from com.bea.wli.sb.management.configuration import ALSBConfigurationMBean
from com.bea.wli.config import Ref
from java.lang import String
from com.bea.wli.monitoring import StatisticType
from com.bea.wli.config import Ref
from com.bea.wli.sb.util import Refs
from com.bea.wli.sb.management.configuration import CommonServiceConfigurationMBean
from java.lang import String
from com.bea.wli.monitoring import StatisticType
from com.bea.wli.config import Ref
from com.bea.wli.sb.util import Refs
from com.bea.wli.sb.management.configuration import CommonServiceConfigurationMBean
adminUser = sys.argv[1]
adminPassword = sys.argv[2]
adminUrl = sys.argv[3]
project = sys.argv[4]
service = sys.argv[5]
action = sys.argv[6]
connect(adminUser,adminPassword,adminUrl)
domainRuntime()
print('WLST Connected')

Create a session name

sessionName = String("SessionScript"+Long(System.currentTimeMillis()).toString())
print('... after session. Session is: ', sessionName)

Get the session MBean and create a session

sessionMBean = findService(SessionManagementMBean.NAME,SessionManagementMBean.TYPE)
print('SessionMBean is: ', sessionMBean)
sessionMBean.createSession(sessionName)
print(String('Session was created ... ').concat(sessionName))

Get the ProxyServiceConfigurationMBean specific to our session

mbean = findService(String("ProxyServiceConfiguration.").concat(sessionName),'com.bea.wli.sb.management.configuration.ProxyServiceConfigurationMBean')

Creates a reference to a folder and 'ProxyServices' is a folder in the project and 'ProxyServices' is a folder in the project

projectName = Refs.makeParentRef(project + '/')
proxyRef = Refs.makeProxyRef(projectName, service)
if action == 'disable' :
print "Disabling " + service +" has been completed"
mbean.disableService(proxyRef)
else :
print "Enabling " + service +" has been completed"
mbean.enableService(proxyRef)

Now commit (activate) the changes

sessionMBean.activateSession(sessionName, "disabled PS")
print
disconnect()
exit()

Place all files in a single folder.

From CMD, Navigate to folder and just call ant

Verify from OSB Portal, the service will be in disabled/enabled format in Operational Settings Tab.