Quite a lot of music software comes with a random riff generator. This stuff isn’t hard. But now it’s convenient as well: DJenerator Random Metal Riff Generator by Ross McMillan. Be sure to click “Settings” (it’s a dropdown) and have a good play with it. You can also get the source code. Some people are already working on a techno version.