xeals / signal-back

Decrypt Signal encrypted backups outside the app
Apache License 2.0
700 stars 66 forks source link

Panic: undefined SMS type: 2 #4

Closed troygiorshev closed 6 years ago

troygiorshev commented 6 years ago

As the title says, the program fails with that error. I worked around it by modifying format.go to simply skip any SMS where it couldn't assign the type number to a meaningful variable.

As an aside, after doing that, this program worked perfectly! I copy-pasted the xml into an online xml to json converter, and that worked just fine. From what I can tell, it didn't miss any SMS messages (though I didn't look that hard).

ifed3 commented 6 years ago

@troygiorshev, would you mind forking and pasting your updates. I'm getting a similar error with a different SMS type (10551316) but I'm not well versed in Go to make the adequate changes.

troygiorshev commented 6 years ago

Honestly, I've never used Go, I sorta briefly learned it just to solve this issue. So the solution is embarrassingly bad. All I did was change (in format.go) the default behavior bottom switch case (in translateSMSType) to return "types.SMSQueued", using that to represent "unknown type". I wasn't gonna learn how to make new types or global variables in Go, though that would probably be better.

All I did was:

Line 165 from: panic(fmt.Sprintf("undefined SMS type: %v", t)) to return types.SMSQueued

Then, I changed line 126 from smses.SMS = append(smses.SMS, sms) to (Something like)

if sms.Type != SMS.queued(
    smses.SMS = append(smses.SMS, sms)
}

So it just skips any sms it can't figure out.

The better way is probably to figure out what all of these unknown SMS types mean and deal with them accordingly.

xeals commented 6 years ago

Apologies for not seeing this earlier. Github decided not to notify me.

Currently the SMS protocol lookups have to be done to match Signal's own internal ones (because it defines protocols outside those of SMS B&R). It currently panics on protocols it doesn't recognise.

I'll hook up the other standard ones, so test that.

@ifed3, could you tell me details of the message? Was it drafted, in the outbox, failed to send, etc.? Secure or insecure conversation?

xeals commented 6 years ago

The latest commit should fix it for both issues. If it's still occurring, let me know.