Note that 2m≡1(mod7), which means that m=3k for some positive integer k. Now we have
23k−1=(2k−1)(22k+2k+1)=7n2.
Denote A=2k−1 and B=22k+2k+1. Let d be the greatest common divisor of A and B, and note that d is odd. Furthermore, d divides B−A2=2k+2k+1=3⋅2k, and since d is odd, it follows that d=1 or d=3.
Therefore, we have exactly four possibilities for factorising A and B. In all cases we assume that a and b are relatively prime positive integers.
Case 1. A=7a2 and B=b2. This is not possible because (2k)2<B<(2k+1)2, i.e. B cannot be a perfect square.
Case 2. A=a2 and B=7b2. If k≥2, note that B≡1(mod4), i.e. 7b2≡1(mod4), which is not possible. Therefore, k=1 and we get (m,n)=(3,1).
Case 3. A=21a2 and B=3b2. Analogously to the previous case we can conclude that k=1 necessarily, but that is not possible in this case, since 21a2=A=21−1=1.
Case 4. A=3a2 and B=21b2. Therefore, A is divisible by 3, i.e. 2k≡1(mod3), from which it follows that k=2l for some positive integer l. Now we have
(2l−1)(2l+1)=3a2,
and since 2l−1 and 2l+1 are relatively prime, we have only two possibilities:
2l−12l+1=c2=3d2or2l−12l+1=3c2=d2,
where c and d are relatively prime positive integers.
In the first option, if l≥2 we have 3d2≡1(mod4), which is not possible. Therefore, l=1 and we get another solution (m,n)=(6,3).
In the second option, we have 2l=(d−1)(d+1). Since the greatest common divisor of d−1 and d+1 is at most 2 and their product is a power of 2, we can conclude that d−1=2, i.e. that l=3, but then 3c2=23−1=7, which is not possible.
Finally, all solutions of the given equation are (m,n)=(3,1) and (m,n)=(6,3).