I'm trying to simulate a fraudulent commitment transaction on lightning. How would you submit an earlier commitment transaction. It doesn't seem like this can be done with a command. Does anyone know where in the code (LND or C-lightning) you could change it to do this?
As far as I know the lightning clients that I know of (LND, c-lightning) do not offer this possibility through their API.
So you'd be right to patch the code yourself. For LND, you should have a look at the ForceClose, which is the code that handles unilateral closing of a channel. It uses a CloseTx which it get's from the wire. If you could change that Tx to an earlier one, you would unilaterally close the channel with a fraudulent commitment transaction.
Take a look at the code here: https://github.com/lightningnetwork/lnd/blob/c37ea68ba6e1153478419914d1aa3bfcaf7abe5b/lnwallet/channel.go#L5684