Not sure how to crack a chained SHA-256 hash
#1
I've got a chain of hashes where each one is put through SHA-256 to produce the next, but I need a way to work out a hash earlier in the chain via brute-force. How would I set this up with hashcat?

If my problem is unclear, imagine my hasher takes a number, triples it, then applies modulo 50. If I start with 12, I get:
12, 36, 8, 24, 22, 16, 48
I need a way of working out that 8 came before 24, but it doesn't need to be 8 specifically. It can be 108, it will still work fine for what I need. Ideally, it should be able to state what was a few back (that 12 was 4 before 22).
#2
there's no way to do that with the existing kernels, but since we went OSS you can hack one of them to do what you like. I'd recommend kernel source of -m 1400 as a template