czwartek, 2 czerwca 2016

F5 VPN Client under Linux

It looks like many places have outdated or plain wrong instructions about connecting to f5 VPN under Linux is a bit outdated so a quick reminder:
  1. Ignore web plugin/extension, it probably won't work anyway under 64 bit browser with disabled NPAPI support
  2. download and extract
  3. execute
  4. f5fpc --start -t

piątek, 29 maja 2015

Most common (anti-)pattern

I guess that by now everyone knows that Singleton is considered mostly harmful and definitely overused. Many people have said that it hinders testing but there is nothing more convincing that unit test that completes fine on its own but mysteriously fails when whole suite is launched. It looks strange when even after doing reset() and adding new when() rules the mock created by Mockito behaves in wrong way. It is a lot less mysterious when you find a singleton that was injected with mock object on class load and ignores the fact that whole Spring context was created and destroyed multiple times ever since.

czwartek, 26 marca 2015

ORA-00932: inconsistent datatypes: expected - got (N)CLOB

If you are modifying query and suddenly started getting ORA-00932 out of nowhere, remember that this error comes not only from comparing CLOB column with something else but also from using distinct on table that has CLOB columns.

poniedziałek, 15 grudnia 2014

CTF PGS Contest Solutions

Here is how I approached challenges from PGS CTF contest. Task are in order that I was able to solve them. Rules stated that the searched flag will start with PGS_ prefix and will be human readable. More complete solution is available at .

4. deepspace

That was the first one that "clicked" for me. I had remembered seeing same image few days before. Comparing provided SVG file with the original "Pioneer plaque" it was easy to spot modified "ray". decoding binary to string gave PGS_PIONEER. Deep space indeed.

5. 01

Just an text file full of 0 and 1. I guessed it was a binary image and I was right. The file size could be factored only in one way so I just had to check 2 possibilities - is it weight * width or other way around. I added line breaks and header and loaded the file directly to Gimp just to see rotated QR Code. After feeding it to some online decoded I got PGS_PRIMENUMBERS.

6. matrioshka

Inside provided file there was part that looked like Base64 encoded. After decoding I got something that I took as Windows Exe file. In reality it was an HDD image for VM, and the string that confused me was from bootloader. After mounting it in VirtualBox I found a file with PGS_formatmaster inside.

10. noneshallpass

After trying to brute force 5-9 letter passwords with starting with "PGS_" prefix I finally noticed there are two files in the archive, besides the flag there is also a PGS logo, also available on their site. Was there known plain text attack on Zip files? Quick googling pointed to tools that were happy to decode the archive without the password. I still wonder what was it. The flag turned out to be: PGS_KNOWNTEXT.

1. whereami

I went back to first one. It is supposed to be easy, right? It took me some time to notice that first two numbers are geographic coordinates, then it was easy to spot that 3rd number is just an index of letter in name of city pointed by coords. Decoded flag: PGS_WORLDISSMALL.

2. math...

That equation is quite long what if I remove digits? Still doesn't look readable. But wait, in sample CTF there was morse code, what if I remove everything beside "." and "-"? The result is PGS_MORSEFOREVER. Yeah, it took me forever - trying to feed that whole equation to Wolfram Alpha and expecting some enlightening output.

3. matrix

I wasted a lot of time on this one. I was sure the information is hidden with gif shuffle and that I just need to guess the password. So I tried running it with anything related to the "Matrix" movie. It got me nowhere. Then I decided to change colors palette, maybe something will appear where I convert everything to green? Lucky for me the way the colors palette looked in Gimp reminded me of something. In the end it was all about Data Matrix barcode and the decoded flag was: PGS_palFun

7. haxor

Just launching this APK file on Android (I used GenyMotion) created text file with flag: PGS_LOVES_ANDROID. Strangely enough I tried to solve it without running, using decompiled code, as the app was just XORing 3 strings but I didn't get the correct result.

8. bigmem

I still don't know what is the proper solution. After unsuccessful attempts as running this binary under Linux I guessed that all haiku related symbols might be realted to HaikuOS and not type of poetry. Sadly even running the binary under right OS still didn't produce any output. Good thing about Haiku is that it has GDB included. After I changed "ctfdelay" method to single "ret" instruction there still was no visible output. I changed the format string "%c%c%c%c%c%c%c%c%c" to "%x%x%x%x%x%x%x%x%x" - then I got D7C7E26DC1E2C3C9C9. And this is where my ideas ended - dropping most significant bit from each byte made it a bit more readable, but it still didn't match PGS_ pattern. So I resorted to guessing. I assumed same bytes will encode same letters and the flag will match "PGS_.S.(.)\1". Lucky for me one of few words in dictionary matching ".S.(.)\1", and the only related to IT, was "ASCII". So PGS_ASCII it is.

while working with this task I stumbled upon ODA, it is quite handy when quick disassemblation is required.

9. tweet(y)

After many attempts to somehow load the file in GIMP I finally tried Audacity. The file was "Looney Tunes Outro". After looking at different spectrum graphs it was easy to see artificial spike on higher frequency. After filtering it with High/Low pass it sounded like a telegraph. So I wasted my time trying to decode it as Morse code. After that i tried to decode it as some kind of barcode. In the end it was just a standard binary code but I didn't notice it until I loaded it into Sonic Visualiser. I finally got the last flag: PGS_soundofsilence

On top - how I have been looking at the file, on bottom - how I should have

It was my first CTF contest and I wasted spent around 30 hours on it, mostly stuck exploring some dead ends. It is hard to remove old ideas from head and restart with clean mind - switch between them helps a bit. Of course I wouldn't do it if I didn't enjoy it, I guess everyone love IT related puzzles and I am not an exception.

I would love to see more feedback during competition - for example live results/ranking, like the one in Google Code Jam. I am not sure how it is handled in other CTF contests.

piątek, 17 października 2014

Spring component-scan classpath pitfall

There is one non-intuitive behavior with Spring's component-scan - it works on _current_ classpath. For example:

Project A


    <component-scan package="x">

Project B


    <import resource="classpath:/a.xml" /> 

    <component-scan package="x.y">

This will load all components from  package "x.y" already at <import> tag.  It can lead to very strange errors in bigger projects (sudden appearance of "NoSuchBeanDefinitionException: No qualifying bean of type" errors) and  trying to cherry-pick used imports/components might be hard or even impossible.
There is similar issue with integration tests - Spring will scan all classes in package, including test files, for components. If you are using inner static classes to override context configuration spring will pick up all of them. And that problem might propagate if you are reusing test support code (<classifier>tests</classifier>). Lucky this one is easy to deal with: it is possible to filter it out:
<context:component-scan base-package="my.package" >
        <context:exclude-filter type="annotation" expression="org.springframework.context.annotation.Configuration" />
        <context:exclude-filter type="regex" expression=".*IT" />
        <context:exclude-filter type="regex" expression=".*Test" />

piątek, 7 czerwca 2013

Unable to find a public constructor for class org.jboss.resteasy.core.AsynchronousDispatcher

Takim wspaniałym komunikatem wita nas próba zdeployowania prostej aplikacji używającej RestEasy na JBossa 7.1. Obejście jest proste ale mało wygodne. Trzeba wyłączyć automatyczne skanowanie w web.xml:
I ręcznie podać usługi np.:
Inne opcje konfiguracyjne są w dokumentacji . A skoro już jesteśmy przy temacie AS: Tak, nie ma to jak wersja serwera aplikacji z dopiskiem Final, która od czasu do czasu kompletnie rozwala serwowany kod JavaScript

piątek, 22 lutego 2013

File extensions recognized by Drools

Just in case anybody else needs it. I didn't know why KieRepository didn't pick up one file, of course I had a typo in file extension.

Drools Rule Language.drl
Drools XML Rule Language.xdrl
Drools DSL.dsl
Drools DSL Rule.dslr
Drools Rule Flow Language.rf
jBPM BPMN2 Language.bpmn, .bpmn2
Decision Table.xls
Binary Package.pkg
Drools Business Rule Language.brl
Change Set.xcs
Predictive Model Markup Language.pmml
Knowledge Descriptor.descr
List is copied from org.drools.builder.ResourceType.