A Kronecker Product identity
Your effort is valiant, but I can tell you from experience that it is helpful to avoid getting into the quagmire of modular arithmetic (or of directly indexing of a Kronecker product at all) when possible. Here's how I would prove the statement:
First, it helps to note that for any column-vectors $u,v,$ we have $$ \operatorname{vec}(uv^T) = v \otimes u $$ I think you will find proving this statement to be a useful exercise. In fact, I prefer to take the above equation to be the definition of the vectorization operator (wikipedia defines the operator as "stacking the columns").
Let $e_1,\dots,e_n$ denote the canonical basis (i.e. the columns of the $n \times n$ identity matrix). Let $X = (x_{ij})_{i,j = 1}^{m,n}$. We have $$ \begin{align} \operatorname{vec}(AXB) &= \operatorname{vec}\left(A\left(\sum_{i=1}^m \sum_{j=1}^n x_{ij} e_ie_j^T\right)B\right) \\ & = \sum_{i=1}^m\sum_{j=1}^n x_{ij} \operatorname{vec}(Ae_ie_j^TB) \\ & = \sum_{i=1}^m\sum_{j=1}^nx_{ij} \operatorname{vec}([Ae_i][B^Te_j]^T) \\ &= \sum_{i=1}^m\sum_{j=1}^nx_{ij} [B^Te_j]\otimes [Ae_i] \\ &= (B^T \otimes A)\left(\sum_{i=1}^m\sum_{j=1}^nx_{ij} e_j \otimes e_i\right) \\ &= (B^T \otimes A)\left(\sum_{i=1}^m\sum_{j=1}^nx_{ij} \operatorname{vec}(e_i e_j^T)\right) \\ &= (B^T \otimes A)\operatorname{vec}\left(\sum_{i=1}^m\sum_{j=1}^nx_{ij} e_i e_j^T\right) = (B^T \otimes A)\operatorname{vec}(X) \end{align} $$